-
Notifications
You must be signed in to change notification settings - Fork 13
Templates
See also Graphity Processor resource templates for server-side Linked Data templates.
Graphity Client XSLT stylesheets work by transforming raw RDF/XML. 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. The default stylesheets are implemented for Jena's RDF/XML layout which groups statements by subject but does not nest:
-
/rdf:RDF
which represents the RDF model -
/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 isconcat(namespace-uri(), local-name())
-
/rdf:RDF/rdf:Description/*/@rdf:resource
object resource -
/rdf:RDF/rdf:Description/*/@rdf:nodeID
object blank node ID
There are currently following default template modes that should be reused by Graphity applications, if possible:
-
rdf:RDF
- model and resource level templates found in the master layout stylesheet-
gc:ReadMode
which renders full resource description -
gc:ListMode
renders a list of resources (possibly with descriptions) -
gc:TableMode
renders a table with resources as rows and properties as columns -
gc:ThumbnailMode
renders a gallery of thumbnails -
gp:ConstructMode
which renders an RDF/POST form for creation of new resource -
gc:EditMode
which renders an RDF/POST form for editing of existing resource
-
-
rdf:Description
- resource level templates found in the per-vocabulary import stylesheets- default one which renders full resource description (by default header and property list)
-
gc:DescriptionMode
renders resource description -
gc:HeaderMode
renders resource header (by default with type information) -
gc:PropertyListMode
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/org/graphity/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. XSLT keys are used to lookup resource descriptions in the RDF/XML tree, for example key('resources-by-page-of', $absolute-path)
where the key definition is:
<xsl:key name="resources-by-page-of" match="*[@rdf:about]" use="gp:pageOf/@rdf:resource"/>
The transformations are plugged into the application using ModelXSLTWriter
which implements JAX-RS MessageBodyWriter
and has to be registered as a provider in ApplicationBase
. The main stylesheet that gets invoked by ModelXSLTWriter
to produce response body (in case (X)HTML is requested) is configurable in web.xml. ModelXSLTWriter
passes a number of JAX-RS parameters into the XSLTBuilder
, such as $gp:baseUri
, $gp:requestUri
, $gp:orderBy
, $gc:lang
, $gc:mode
etc.
DataManager
implements URIResolver
to resolve known URIs accessed from XSLT into locally cached copies of ontologies that are stored under /src/main/resources/org/graphity/client/vocabulary
. 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.