Bundle the ontology and the stylesheet for your own vocabulary as a reusable package

A package is a namespace ontology and an XSLT stylesheet, published as Linked Data behind a package URI. Developers can create custom packages for their own domain vocabularies. The process has four steps.

Write package ontology

Create ns.ttl describing both the document the registry serves it as and the ontology inside it, with the vocabulary import and the views:

<> a dh:Item ;
    dct:title "Schema.org ontology" ;
    foaf:primaryTopic <#> .

<#> a owl:Ontology ;
    owl:imports <https://schema.org/> .

# Attach view to a property
schema:knows ldh:view :PersonKnows .

:PersonKnows a ldh:View ;
    dct:title "Knows" ;
    spin:query :SelectPersonKnows .

:SelectPersonKnows a sp:Select ;
    sp:text """
    SELECT DISTINCT ?person
    WHERE { GRAPH ?graph { $about schema:knows ?person } }
    ORDER BY ?person
    """ .

The dct:title on <> is not optional. A write is held to the constraints of the document as it will be written, and a LinkedDataHub document must be titled, so an ns.ttl that describes only the ontology is refused 422 Unprocessable Entity when it is pushed.

Write XSLT stylesheet

Create the stylesheet — name the file for the vocabulary it covers — with XSLT templates using system modes like ac:*, ldh:* and xhtml:*. See the Stylesheets reference for template customization patterns.

<xsl:template match="schema:knows" mode="ac:PropertyEditor"/>

Publish package metadata

Publish the descriptor as Linked Data at your package URI, naming the ontology beside it:

<> a dh:Container ;
    dct:title "Schema.org" ;
    foaf:primaryTopic <#this> .

<#this> a lds:Package ;
    dct:title "Schema.org Package" ;
    dct:description "Schema.org vocabulary support" ;
    lds:ontology <ns/#> .

Then upload the stylesheet into the package document and add ac:stylesheet naming that upload, which is where a registry published with ldh push gets it:

package="https://packages.example.com/schema.org/"

upload=$(ldh add file --title schema.xsl --file schema.xsl "$package")
echo "INSERT { <${package}#this> <https://w3id.org/atomgraph/client#stylesheet> <$upload> } WHERE { }" | ldh patch "$package"

A dataspace importing the package dereferences its descriptor, ontology and stylesheet anonymously, so all three have to be readable without a certificate.

Test installation

Declare the ldh:import triple in a test dataspace's settings document — see Management for the command.