Packages

Packages are reusable bundles of ontologies and stylesheets that provide vocabulary support with custom rendering for specific RDF vocabularies.

Note: Packages are declarative only (RDF + XSLT). They contain no Java code and integrate at installation-time, not runtime.

What are packages?

A LinkedDataHub package is a reusable component that bundles together a vocabulary ontology and XSLT templates into a single installable unit. Packages enable:

  • Rapid application setup with pre-configured domain vocabularies
  • Sharing and reusing common vocabulary definitions
  • Custom rendering for vocabulary-specific resources
  • Modular extension of dataspace functionality

Package structure

Each package consists of two files:

ns.ttl - Package ontology
An RDF ontology file that imports the external vocabulary using owl:imports and defines template blocks (ldh:template) for custom views. Template blocks are SPARQL-based views attached to RDF types from the imported vocabulary.
layout.xsl - XSLT stylesheet
XSLT transformation file with templates that override default rendering using system modes like bs2:* (Bootstrap 2.3.2 components) and xhtml:* (XHTML elements). See Stylesheets reference for details on XSLT customization.

Package files are organized in the LinkedDataHub-Apps repository:

packages/
├── package-name/
│   ├── ns.ttl         # Ontology with template blocks
│   └── layout.xsl     # XSLT stylesheet

Package metadata is published as Linked Data that resolves from the package URI (e.g., https://packages.linkeddatahub.com/skos/#this).

Package metadata

Package metadata is published as Linked Data that resolves from the package URI using standard LinkedDataHub properties:

lapp:Package
The RDF class for package descriptors
rdfs:label
Human-readable package name
dct:description
Package description and purpose
ldt:ontology
Points to the package ontology URI (from LDT vocabulary)
ac:stylesheet
Points to the package stylesheet URI (from AtomGraph Client vocabulary)

Example package metadata:

@prefix lapp: <https://w3id.org/atomgraph/linkeddatahub/apps#> .
@prefix ldt:  <https://www.w3.org/ns/ldt#> .
@prefix ac:   <https://w3id.org/atomgraph/client#> .

<https://packages.linkeddatahub.com/skos/#this> a lapp:Package ;
    rdfs:label "SKOS Package" ;
    dct:description "SKOS vocabulary support with custom templates" ;
    ldt:ontology <https://raw.githubusercontent.com/AtomGraph/LinkedDataHub-Apps/master/packages/skos/ns.ttl#> ;
    ac:stylesheet <https://raw.githubusercontent.com/AtomGraph/LinkedDataHub-Apps/master/packages/skos/layout.xsl> .

Package ontology

The package ontology file contains two layers:

Vocabulary import

Imports the external vocabulary using owl:imports. See Ontologies reference for ontology management details.

<https://raw.githubusercontent.com/AtomGraph/LinkedDataHub-Apps/master/packages/skos/ns.ttl#> a owl:Ontology ;
    owl:imports <http://www.w3.org/2004/02/skos/core> .

Template blocks

SPARQL-based views attached to RDF types from the imported vocabulary:

skos:Concept ldh:template ns:NarrowerConcepts .

ns:NarrowerConcepts a ldh:View ;
    dct:title "Narrower concepts" ;
    spin:query ns:SelectNarrowerConcepts .

ns:SelectNarrowerConcepts a sp:Select ;
    sp:text """SELECT DISTINCT ?narrower
    WHERE { GRAPH ?graph { $about skos:narrower ?narrower } }
    ORDER BY ?narrower""" .

Template blocks define custom views that appear in the UI when viewing resources of the specified type.

Package stylesheet

XSLT templates using system modes to override default rendering:

<!-- Hide properties from default property list -->
<xsl:template match="skos:narrower | skos:broader" mode="bs2:PropertyList"/>

<!-- Override XHTML head elements -->
<xsl:template match="*" mode="xhtml:Style">
    <!-- Custom styles -->
</xsl:template>

Available system modes include:

  • bs2:* - Bootstrap 2.3.2 components (PropertyList, Form, etc.)
  • xhtml:* - XHTML elements (Style, Script, etc.)
  • Additional modes documented in the Stylesheets reference

Installing packages

Installation requires Control access to the administration application. See the step-by-step installation guide for detailed instructions.

Installation will fail if these files do not exist.

Installation process

When you install a package, the system performs the following steps:

  1. Fetches package metadata from the package URI
  2. Hashes the package ontology URI using SHA-1 to create a unique document slug
  3. Downloads package ontology (ns.ttl) and PUTs it as a document to ${admin_base}ontologies/{hash}/ where {hash} is the SHA-1 hash of the ontology URI
  4. Adds owl:imports from the namespace ontology to the package ontology in the namespace graph (${admin_base}ontologies/namespace/)
  5. Clears and reloads the namespace ontology from cache to pick up the new imports
  6. Downloads package stylesheet (layout.xsl) and saves it to /static/{package-path}/layout.xsl where {package-path} is derived from the package URI (e.g., com/linkeddatahub/packages/skos/ for https://packages.linkeddatahub.com/skos/)
  7. Updates master stylesheet at /static/xsl/layout.xsl by adding import:
    <xsl:import href="../com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/layout.xsl"/>  <!-- System -->
    <xsl:import href="../com/linkeddatahub/packages/skos/layout.xsl"/>  <!-- Package (added) -->

Uninstalling packages

Packages can be safely uninstalled, which removes:

  • Package ontology imports from the application
  • Package-specific data and resources
  • Associated queries and stylesheets

Note: Uninstalling a package does not remove user-created data that uses the package's vocabulary.

Architecture

Installation-time vs runtime

Packages use installation-time composition, NOT runtime composition:

  • ✅ Package content is integrated during installation (via JAX-RS endpoints)
  • ✅ Ontology and XSLT are pre-composed before being loaded
  • ✅ No runtime overhead
  • ❌ No dynamic package loading at request time

HTTP endpoints

Package installation and uninstallation is performed via system endpoints on the admin application. See packages/install and packages/uninstall in the HTTP API reference.

File system structure

After installing the SKOS package:

webapp/
├── static/
│   ├── com/
│   │   └── linkeddatahub/
│   │       └── packages/
│   │           └── skos/
│   │               └── layout.xsl          # Package stylesheet
│   └── xsl/
│       ├── layout.xsl                      # End-user master stylesheet
│       └── admin/
│           └── layout.xsl                  # Admin master stylesheet

Creating custom packages

Developers can create custom packages for their own domain vocabularies. The process involves:

Write package ontology

Create ns.ttl with vocabulary import and template blocks:

<https://raw.githubusercontent.com/you/repo/master/packages/schema.org/ns.ttl#> a owl:Ontology ;
    owl:imports <http://schema.org/> .

# Attach template block to a vocabulary class
schema:Person ldh:template :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
    """ .

Write XSLT stylesheet

Create layout.xsl with XSLT templates using system modes like bs2:* and xhtml:*. See the Stylesheets reference for template customization patterns.

<xsl:template match="schema:knows" mode="bs2:PropertyList"/>

Publish package metadata

Publish package metadata as Linked Data at your package URI:

<https://packages.linkeddatahub.com/schema.org/#this> a lapp:Package ;
    rdfs:label "Schema.org Package" ;
    dct:description "Schema.org vocabulary support" ;
    ldt:ontology <https://raw.githubusercontent.com/you/repo/master/packages/schema.org/ns.ttl#> ;
    ac:stylesheet <https://raw.githubusercontent.com/you/repo/master/packages/schema.org/layout.xsl> .

Ensure the metadata contains ldt:ontology and ac:stylesheet properties pointing to the package resources.

Test installation

Use the CLI to test your package installation:

install-package.sh \
  -b "https://localhost:4443/" \
  -f ssl/owner/cert.pem \
  -p "$cert_password" \
  --package "https://packages.linkeddatahub.com/schema.org/#this"

Available packages

A curated list of available packages can be found in the LinkedDataHub-Apps repository. Each package directory contains the package ontology (ns.ttl) and stylesheet (layout.xsl) files.