RDF resources and their management

Within documents, users can create RDF resources, i.e. instances of both built-in and user-defined RDF classes.

Built-in classes are defined in system ontologies while user-defined classes are defined in user ontologies.

User-defined classes

User-defined classes live in the dataspace's namespace ontology, which is managed in the admin dataspace. A class becomes creatable in the UI once it has a constructor: it then appears in the Create dropdown alongside the built-in classes, and its instances are created and edited using the same forms. See Change the model for a walkthrough of defining classes, constructors and constraints.

Built-in classes

LinkedDataHub's built-in classes have pre-defined constructors, constraints and often a customized UI rendering (implemented by overriding generic XSLT templates with type-specific templates) as well, for example a query editor or a chart.

The table lists the built-in classes creatable from the Create dropdown; the two content block classes, ldh:XHTML and ldh:Object, are documented on the Content blocks page.

Built-in classes by type
Type Class Description
ASK sp:Ask SPARQL ASK query
Dataspace lds:Dataspace Remote LinkedDataHub dataspace
CONSTRUCT sp:Construct SPARQL CONSTRUCT query
CSV import ldh:CSVImport Asynchronous CSV data import
DESCRIBE sp:Describe SPARQL DESCRIBE query
File nfo:FileDataObject An uploaded file, stored content-addressed under uploads/
Graph chart ldh:GraphChart Chart based on CONSTRUCT/DESCRIBE query results
RDF import ldh:RDFImport Asynchronous RDF data import
Result set chart ldh:ResultSetChart Chart based on SELECT query results
Select sp:Select SPARQL SELECT query
Service sd:Service SPARQL service (identified by its endpoint URL)
View ldh:View View based on SELECT query results

Resources that have customized UIs (such as queries, views, charts) are documented in more detail below.

Queries

A query block with the SPARQL editor

Queries are SPARQL 1.1 query strings that can be executed interactively. A query may name the SPARQL service it executes against; otherwise it runs against the dataspace's own service.

A query is a resource typed by its SPARQL form, carrying the query string as sp:text:

<#select-categories-query> a sp:Select ;
    dct:title "Select categories" ;
    sp:text '''PREFIX  schema: <https://schema.org/>

SELECT DISTINCT  ?category
WHERE
  { GRAPH ?doc
      { ?category  a           schema:ProductGroup ;
                  schema:name  ?categoryName
      }
  }
ORDER BY ?categoryName''' .

It is only possible to save valid SPARQL 1.1 query strings. SPARQL updates are currently not supported.

Charts

A chart block rendering SPARQL results

Charts can render both types of SPARQL results:

  • tabular SELECT results (ldh:ResultSetChart)
  • graph results of DESCRIBE and CONSTRUCT (ldh:GraphChart)

A chart plots the results of its query wherever the query runs, so a chart over a query that names an external service with ldh:service plots that endpoint's data.

A chart resource is easily confused with the chart layout mode in views. The layout mode renders view results as a chart on the fly, while a chart resource additionally stores the chart type as well as the category and series information: variable names in the case of tabular results, and property URIs in the case of graph results.

RDF vocabulary

A chart references its query with spin:query and describes its rendering with the following properties:

Vocabulary properties and what they apply to
Property Applies to Description
ldh:chartType both One of ac:Table, ac:LineChart, ac:BarChart, ac:ScatterChart, ac:Timeline
ldh:categoryVarName ldh:ResultSetChart Name of the SELECT variable that provides the category values
ldh:seriesVarName ldh:ResultSetChart Name(s) of the SELECT variable(s) that provide the series values
ldh:categoryProperty ldh:GraphChart URI of the property that provides the category values
ldh:seriesProperty ldh:GraphChart URI(s) of the property(ies) that provide the series values

The default chart type is the table. Other chart types might not apply to all result data; for example, a scatter chart needs numeric or datetime values for both category and series.

A complete chart is a chain of three resources — the query, the chart description, and an object block that places it on a document:

<#category-revenue-query> a sp:Select ;
    dct:title "Category revenue" ;
    sp:text '''PREFIX schema: <https://schema.org/>

SELECT ?categoryName (SUM(?sale) AS ?revenue)
WHERE {
    GRAPH ?orderGraph {
        ?order schema:orderedItem ?orderItem .
        ?orderItem schema:orderedItem ?product ;
                   schema:price ?sale .
    }
    GRAPH ?productGraph {
        ?product schema:category ?category .
    }
    GRAPH ?categoryGraph {
        ?category schema:name ?categoryName .
    }
}
GROUP BY ?category ?categoryName
ORDER BY DESC(?revenue)''' .

<#category-revenue> a ldh:ResultSetChart ;
    dct:title "Revenue by category" ;
    spin:query <#category-revenue-query> ;
    ldh:chartType <https://w3id.org/atomgraph/client#BarChart> ;
    ldh:categoryVarName "categoryName" ;
    ldh:seriesVarName "revenue" .

<#category-revenue-block> a ldh:Object ;
    dct:title "Revenue by category" ;
    rdf:value <#category-revenue> .

Multiple ldh:seriesVarName values (ldh add result-set-chart takes --series-var-name once per series) plot one series per named result variable, in the order the query's SELECT projects them — see the demo's revenue-by-carrier chart, which pivots three carriers into three series with conditional aggregation.

Views

A view renders the results of a SPARQL SELECT query as an interactive, paginated list of the resources the query selects, with faceted search and parallax navigation. Views have their own page: Views.

Live example

The block below is not a code snippet — it is an actual query block embedded in this document, executing against the Northwind Traders dataspace's SPARQL endpoint. The query, the service it runs against, and the block that places it here are three plain RDF resources in this very document.

Title
Query another dataspace

Management

Resources can only be managed when the Properties layout mode is active.

Resource management actions
Action Description
Create Click the Create dropdown at the bottom of the page. Fill out the fields in the form that appears. Click Save.
Update Click the button in the top-right corner of the resource block (it appears when you move the mouse close to that corner). Make changes in the form that appears. Click Save.
Delete Click the button in the top-right corner of the resource block. Click the button to delete the resource.

To query data and create resources step-by-step, follow the Query data and Create resources guides