-
Notifications
You must be signed in to change notification settings - Fork 145
LinkedDataHub Packages
This document describes the LinkedDataHub package system for extending dataspaces with reusable vocabulary and UI components.
LinkedDataHub packages provide vocabulary support (RDF ontologies) with custom presentation (XSLT templates) for rendering specific RDF vocabularies. Packages are declarative, installation-time composed, and fully data-driven.
- 📦 Modular - Packages are external, independently versioned components
- 🔌 Pluggable - Install/uninstall via REST API without code changes
- 🎨 Unified - Vocabulary and presentation defined together
- ⚡ Performant - Pre-composed at installation time, no runtime overhead
Packages extend LinkedDataHub at two layers:
-
Ontology layer - via
owl:importsfrom namespace ontology to package ontology -
Presentation layer - via
xsl:importfrom master stylesheet to package stylesheet
Each package consists of:
packages/<package-name>/
├── ns.ttl # Ontology with template blocks (ldh:template)
└── layout.xsl # XSLT stylesheet with custom templates
Package metadata is Linked Data that resolves from the package URI (e.g., https://packages.linkeddatahub.com/skos/#this).
packages/skos/
├── ns.ttl # SKOS vocabulary with ldh:template blocks
└── layout.xsl # XSLT templates for SKOS concepts, schemes, collections
Metadata for this package resolves from https://packages.linkeddatahub.com/skos/#this.
Package metadata resolves as Linked Data from the package URI using standard LinkedDataHub properties:
@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> .Note: Uses standard ldt:ontology and ac:stylesheet properties instead of inventing new ones.
Contains two layers:
A. Vocabulary Import
Imports the external vocabulary using owl:imports:
<https://packages.linkeddatahub.com/skos/ns.ttl> a owl:Ontology ;
owl:imports <http://www.w3.org/2004/02/skos/core> .B. Template Blocks (ldh:template)
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
""" .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), xhtml:* (XHTML elements), and others.
install-package.sh \
-b https://localhost:4443/ \
-f ssl/owner/cert.pem \
-p Password \
--package https://packages.linkeddatahub.com/skos/#this# In LinkedDataHub-Apps/demo/skos/install.sh
install-package.sh \
-b "$base" \
-f "$cert_pem_file" \
-p "$cert_password" \
--package "https://packages.linkeddatahub.com/skos/#this"curl -k -X POST \
-E ssl/owner/cert.pem:Password \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "package-uri=https://packages.linkeddatahub.com/skos/#this" \
"https://admin.localhost:4443/packages/install"Before installing packages, master stylesheets must exist in the webapp directory:
-
/static/xsl/layout.xsl- End-user application master stylesheet -
/static/xsl/admin/layout.xsl- Admin application master stylesheet
Default templates are provided at:
src/main/webapp/static/xsl/layout.xsl
src/main/webapp/static/xsl/admin/layout.xsl
These files should be deployed with the application. End-user stylesheet contains:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
<!-- System stylesheet (lowest priority) -->
<xsl:import href="../com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/layout.xsl"/>
<!-- Package stylesheets will be added here by InstallPackage endpoint -->
</xsl:stylesheet>When you install a package, the system:
- Fetches package metadata from the package URI
- Hashes the package ontology URI using SHA-1 to create a unique document slug
-
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 -
Adds owl:imports from the namespace ontology to the package ontology in the namespace graph (
${admin_base}ontologies/namespace/) - Clears and reloads the namespace ontology from cache to pick up the new imports
-
Downloads package stylesheet (
layout.xsl) and saves it to/static/{package-path}/layout.xslwhere{package-path}is derived from the package URI (e.g.,com/linkeddatahub/packages/skos/forhttps://packages.linkeddatahub.com/skos/) -
Updates master stylesheet at
/static/xsl/layout.xslby 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) -->
-
Adds import to application (TODO - currently manual):
<app> ldh:import <package-uri>
Note: The master stylesheet must already exist or installation will fail with InternalServerErrorException.
uninstall-package.sh \
-b https://localhost:4443/ \
-f ssl/owner/cert.pem \
-p Password \
--package https://packages.linkeddatahub.com/skos/#thiscurl -k -X POST \
-E ssl/owner/cert.pem:Password \
-H "Content-Type: application/x-www-form-urlencoded" \
--data-urlencode "package-uri=https://packages.linkeddatahub.com/skos/#this" \
"https://admin.localhost:4443/packages/uninstall"Uninstallation removes the package ontology document, removes the owl:imports triple, deletes the package stylesheet files, and regenerates the master stylesheet.
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
On the admin application
-
POST
/packages/install- Installs a package- Parameter:
package-uri(form-urlencoded) - Requires owner/admin authentication
- Delegates authenticated agent credentials for PUT requests
- Parameter:
-
POST
/packages/uninstall- Uninstalls a package- Parameter:
package-uri(form-urlencoded) - Requires owner/admin authentication
- Parameter:
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
# In admin SPARQL endpoint at <${admin_base}ontologies/{hash}/>
# Package ontology stored as a document where {hash} is SHA-1 of ontology URI
<https://packages.linkeddatahub.com/skos/ns.ttl> a owl:Ontology ;
# ... package ontology content ...
# In admin SPARQL endpoint (namespace graph at <${admin_base}ontologies/namespace/>)
# Namespace ontology imports package ontology
<https://localhost:4443/ns#> a owl:Ontology ;
owl:imports <https://packages.linkeddatahub.com/skos/ns.ttl> .
# In system.trig (application config)
<urn:linkeddatahub:apps/end-user> a lapp:EndUserApplication ;
ldt:ontology <https://localhost:4443/ns#> ;
ac:stylesheet <static/xsl/layout.xsl> ; # Master stylesheet
# ldh:import <package-uri> (TODO - not yet implemented)- SKOS - SKOS vocabulary support (concepts, schemes, collections)
- Create directory:
packages/<name>/ - Write
ns.ttlwith vocabulary and template blocks - Write
layout.xslwith XSLT templates (using system modes likebs2:*,xhtml:*, etc.) - Publish package metadata as Linked Data at
https://packages.linkeddatahub.com/<name>/#this - Ensure the metadata contains
ldt:ontologyandac:stylesheetproperties pointing to the package resources
See the SKOS package for a complete working example.
-
lapp:Package- Package class
-
ldt:ontology- Points to package ontology URI (from LDT vocabulary) -
ac:stylesheet- Points to package stylesheet URI (from AtomGraph Client vocabulary) -
ldh:import- Application property linking to imported packages (from LDH vocabulary)
Problem: Server returns 422 Unprocessable Entity
Solution: Package metadata cannot be loaded. Check:
- Package URI is resolvable and returns RDF
- Package metadata includes
ldt:ontologyand/orac:stylesheetproperties - At least one of ontology or stylesheet is specified
- If using location-mapping, verify the mapping is correct
Problem: Installation fails with InternalServerErrorException
Solution: Master stylesheet doesn't exist. Ensure:
-
/static/xsl/layout.xslexists in webapp directory - File has been deployed with the application
- File is writable by the application server
Problem: Package is installed but UI doesn't change
Solution:
- Check master stylesheet contains the package import
- Clear browser cache
- Verify XSLT template modes match system modes (bs2:, xhtml:, etc.)
- Check template priorities and specificity
Problem: Package ontology classes don't appear in forms/UI
Solution:
- Verify namespace ontology was cleared and reloaded
- Check
owl:importstriple was added to namespace graph - Restart application to reload ontology model if needed
- Packages are declarative only (RDF + XSLT, no Java code)
- Package ontologies use
owl:imports(handled automatically by Jena) - Package stylesheets use
xsl:import(handled by master stylesheet generation) - Template blocks (
ldh:template) are separate from XSLT overrides - Both mechanisms work independently and complement each other