Skip to content
Martynas Jusevičius edited this page May 20, 2020 · 54 revisions

See also server side Linked Data Templates implemented in AtomGraph Processor.

XSLT

AtomGraph Web-Client XSLT stylesheets work by transforming RDF/XML documents. Each layout mode is usually produced by transforming RDF result with a group templates for each level of RDF/XML elements, using additional metadata from vocabularies to improve user experience.

"RDF/XML plain" structure

The default stylesheets are implemented for Jena's "plain" RDF/XML output which groups statements by subject and does not nest resource descriptions:

  • /rdf:RDF which represents the RDF graph
  • /rdf:RDF/rdf:Description resource description which contains properties
  • /rdf:RDF/rdf:Description/@rdf:about (subject) resource URI
  • /rdf:RDF/rdf:Description/@rdf:nodeID (subject) blank node ID
  • /rdf:RDF/rdf:Description/* predicate (e.g. rdf:type) which URI is concat(namespace-uri(), local-name())
  • /rdf:RDF/rdf:Description/*/@rdf:resource object resource
  • /rdf:RDF/rdf:Description/*/@rdf:nodeID object blank node ID

Layout modes

There are currently following default template modes that should be reused by AtomGraph applications, if possible:

  • rdf:RDF - model and resource level templates found in the master layout stylesheet
    • bs2:Block which renders full resource description
    • bs2:List renders a list of resources (possibly with descriptions)
    • xhtml:Table renders a table with resources as rows and properties as columns
    • bs2:Grid renders a gallery of thumbnails
    • bs2:Form which renders an RDF/POST form for creation of new resources (when $ac:forClass is set) or editing of existing resource
  • rdf:Description - resource level templates found in the per-vocabulary import stylesheets
    • bs2:Block renders full resource description (by default header and property list)
    • bs2:Header renders resource header (by default with type information)
    • bs2:PropertyList renders definition list with property names and values (by default grouped by resource types)

The default XSLT 2.0 stylesheets can be found under src/main/webapp/static/com/atomgraph/client/xsl. The master layout stylesheet imports vocabulary-specific resource-level stylesheets, and XSLT import precedence affects selection of the matching template. They use Bootstrap as the front-end HTML/CSS framework.

Keys

XSLT keys are used to lookup resource descriptions in the RDF/XML tree, for example key('resources', $ac:uri) where the key definition is:

<xsl:key name="resources" match="*[*][@rdf:about] | *[*][@rdf:nodeID]" use="@rdf:about | @rdf:nodeID"/>

JAX-RS MessageBodyWriter

The transformations are plugged into the application using DatasetXSLTWriter which implements JAX-RS MessageBodyWriter and has to be registered as a provider in Application. The main stylesheet that gets invoked by DatasetXSLTWriter to produce response body (in case (X)HTML is requested) is configurable in web.xml. DatasetXSLTWriter passes a number of JAX-RS parameters into the XSLTBuilder, such as:

  • $ldt:base
  • $ac:uri
  • $ldt:lang
  • $ac:mode

JAXP URIResolver

DataManager implements URIResolver to resolve known URIs accessed from XSLT into locally cached copies of ontologies that are stored under /src/main/resources/com/atomgraph/client. Other URIs are ignored by default, but DataManager could be extended so that XSLT would load ontologies and execute queries over HTTP. However, this could dramatically increase transformation time.