Templates - AtomGraph/Web-Client GitHub Wiki
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:RDFwhich represents the RDF graph/rdf:RDF/rdf:Descriptionresource 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 isconcat(namespace-uri(), local-name())/rdf:RDF/rdf:Description/*/@rdf:resourceobject resource/rdf:RDF/rdf:Description/*/@rdf:nodeIDobject 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 stylesheetbs2:Blockwhich renders full resource descriptionbs2:Listrenders a list of resources (possibly with descriptions)xhtml:Tablerenders a table with resources as rows and properties as columnsbs2:Gridrenders a gallery of thumbnailsbs2:Formwhich renders an RDF/POST form for creation of new resources (when$ac:forClassis set) or editing of existing resource
rdf:Description- resource level templates found in the per-vocabulary import stylesheetsbs2:Blockrenders full resource description (by default header and property list)bs2:Headerrenders resource header (by default with type information)bs2:PropertyListrenders 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.