vsr2.xsl
- Rubber, meet road.
- The XSL files that implement vsr2.xsl are documented using XSLTdoc.
- This is an implementation of General Strategies for Visualizing RDF Graphs.
- Provenance Capture in vsr2.xsl (which is also discussed below)
- How to use vsr2grf.sh to convert RDF to OmniGraffle files.
- How to create a new Visual Strategy for particular RDF vocabularies, so that your RDF data can be rendered as OmniGraffle, SVG, or (yED-flavored) GraphML.
bash-3.2$ vsr2grf.sh --help
usage: vsr2grf.sh {pml, owl, rdf, rdf-literal, path/to/some.vsr} {graffle, graphml} [-w] [-od path/to/dir] some.rdf+
bash-3.2$ curl -sLO http://dig.csail.mit.edu/2008/webdav/timbl/foaf.rdf
bash-3.2$ vsr2grf.sh rdf graffle -w foaf.rdf
Transforming foaf.rdf to ./foaf.rdf.graffle
bash-3.2$ head foaf.rdf.graffle
<plist version="1.0">
<dict>
<key>ActiveLayerIndex</key>
<integer>0</integer>
<key>ApplicationVersion</key>
<array>
<string>com.omnigroup.OmniGrafflePro</string>
To create a new visual strategy, copy and work from template.vsr.xsl. Replace "template" and "TEMPLATE" with the name of your input visual strategy. For example, if the visual strategy is intended for VoID instance data, use "VOID" (though, we already have one that reproduces the lodcloud diagram).
XSLTDoc of these visual strategies is at vsr/doc/xsltdoc/index.html
template.vsr.xsl depends on rdf2.xsl and rdf-abbrev.xsl (using these imports), discussed below.
Once 2grph.xsl defers to the visual strategy, rdf2.xsl will pick up the initial domain form processing (here) by listing prefix mappings (here) and then deferring to a higher-level visual strategy for each resource occurrence, sorted by namespace precedence (here). Note that the visual strategy is called for each mention of a resource, i.e. if the resource is the subject of 3 triples and the object of 3 other triples, the visual strategy will be asked to render the resource six times. It is up to the visual strategy to determine how many visual elements are formed from these six calls (it could be 1, or 6, or anywhere in between).
If you haven't added any special handling, template.vsr.xsl will pickup rdf2.xsl's deferral here with <xsl:template match="rdf:Description/*" priority="-.25">
. The template announces its arrival at the triple using acv:arriveTriple($owl:sameAs,$subject,$predicate,$object,$deferrer)
, then defers to the contextualized view template using a "global view context". The contextualized view template in turn defers to rdf2.xsl's core Blacklist Checker, passing it 20 or so of the rdf:Property and rdfs:Class General Strategies for Visualizing RDF Graphs classifications.
A summary of the default processing stream:
- graffle5.xsl
- enters at xsl:template match="/"
- inserts GRDDL transformation link.
- defers to visual strategy (i.e. rdf2.xsl) at xsl:apply-templates select="*"
- rdf2.xsl (if you don't override a template for "rdf:RDF")
- enters at xsl:template match="rdf:RDF"
- inserts graphic for namespace prefixes.
- defers to visual strategy (i.e. template.vsr.xsl) at xsl:apply-templates select="current-group()"
- template.vsr.xsl
- enters at xsl:template match="rdf:Description/*" priority="-.25"
- optionally applies contextualized views
- defers to contextualized view at xsl:apply-templates select="." mode="view-contextualized"
- enters contextualized view at xsl:template match="rdf:Description/*" priority="-.25" mode="view-contextualized"
- defers to RDF Blacklist Checker at xsl:apply-templates select="." mode="blacklist_checker", passing down 20 configurations for General Strategies for Visualizing RDF Graphs.
- rdf2.xsl
- enters RDF Blacklist Checker at xsl:template match="*" mode="blacklist_checker" with General Strategies for Visualizing RDF Graphs in scope.
- conditionally makes visual mapping decision to prevent default processing, and logs it.
- if not blacklisted, defers again at xsl:apply-templates select="." mode="default"
- rdf-abbrev.xsl (if your visual strategy doesn't override an appropriate "default")
- enters at xsl:template match="rdf:Description/*" mode="default"
- determines visual mapping characteristics, logging each decision.
- tries to defers to node creation here and here before just doing it itself.
- node creation could defer to itself using view context here.
- creates a visual edge with the vsr2grph API call xsl:call-template name="edge" (whose implementation is provided by one of the many 2grph.xsl's.
- an implementation of 2grph (defaults: src/xsl/to)
- enters template
xsl:template name="node"
andxsl:template name="edge"
.
- enters template
src/xsl/from/rdf-abbrev.xsl implements an abbreviated but relatively naive visual strategy for RDF graphs. It consolidates rdf:Lists and reification, tucks labels, lat/long, and dateTimes into the label of the URI, filters to show only a single language, swaps the "force directionality" of certain properties to lead to a nicer layout, subdues edge colors, colors labels by datatypes, abbreviates blank nodes, implements blacklisting by type, and abbreviates many RDFS axioms and some OWL cardinalities. It depends on rdf2.xsl, described below.
src/xsl/from/rdf2.xsl implements a direct, naive visual strategy for RDF graphs, and also provides a variety of functionality for use by higher-level visual strategies. It handles logging provenance to a Sesame repository (either local in-memory or to a remote), provides RDF indexing, handles namespace prefixes, a visual node identity mapper, blacklist checker, provides utility functions, and provenance logger (implementation here).
The vsr2grph API enables visual strategies to be developed regardless of the target concrete graphical representation. So, once a visual strategy is written, it can be reapplied to create new formats (such as SVG, OmniGraffle, GraphML, GraphViz, etc.) without any modifications. This is achieved through the minimal coupling that the vsr2grph uses. See 2grph.xsl for details of the "second half" of the vsr2grph API: writing output graphical serializations.
vsr2grf.sh constructs a root XSL based on the requested visual strategy (i.e. "x2") and the target graphical system (i.e. "2y"). For example, the following is created when vsr2grf.sh rdf graffle
is used:
<xsl:transform version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:include href="/Users/me/vsr/src/xsl/from/rdf-abbrev.xsl"/> <!-- this is the "x2" -->
<xsl:include href="/Users/me/vsr/src/xsl/to/2graffle5.xsl"/> <!-- this is the "2y" -->
</xsl:transform>
(demo2graffle5.xsl
shows the first prototype of this pattern, using direct calls to the node creation templates without walking the host input format.)
The following diagram shows the execution flow between a "x2" and a "y2", which we describe in stages below.
2y.xsl is responsible for capturing initial control by matching on the document root (/
).
- First, 2y should provide any "header setup" before turning to focus on serializing nodes and edges. This should include a GRDDL transformation pointer in a location thtat will survive "pass through" editing in the native graphical format.
to, which defers to x2.xsl's mode="visual-element"
templates, back to 2y.xsl's templates for the node
and edge
in the appropriate target graphical format.
d2v.xsl
aka domain to visual?
(see also Provenance Capture in vsr2.xsl)
The following functions should be called by the visual strategy to provide justification for decisions about visual mappings of the input data. A shorthand notation is used in the log to distinguish among the kinds of explanations being provided (®
is "Resource", x
is "explain" (no x
implies a pre-explanation "arrival"), ~
is some (known) predicate, o
is an object (either literal or resource), A
is some named "action", ^_
is an "attribute-value" of the visual form). Calls to these functions result in a "human readable" log to stderr that can be helpful while developing the visual strategy, AND the calls result in a PROV-O record about the visual mapping decision into a local or remote Sesame repository. The local repository is appended at the end of the "human readable" log.
The following two lists of explanation functions lead to their implementation, and facilitate a comparison of their the arguments, respectively.
-
® : arriveResource - a visual strategy is "visiting" a particular resource and will either defer to another handler or make the visual mapping decision about this data element.
- x®A : explainResource(action) - the visual strategy handler made a decision to act on the visited resource in a particular "blackbox" way.
- x®^_ : explainResource(property,value) - the visual strategy handler made a decision to apply a property-value to the graphic.
- ®~ : arriveTriple(s,p) - a visual strategy is "visiting" a particular property of a particular resource and will either defer to another handler or make the visual mapping decision about this data property.
-
®~o : arriveTriple(s,p,o) - a visual strategy is "visiting" a particular property value of a particular resource and will either defer to another handler or make the visual mapping decision about this data property.
- x®~oA : explainTriple(action) - the visual strategy handler made a decision to act on the visited resource's data property value in a particular "blackbox" way.
- x®~o^_ : explainTriple(property,value) - the visual strategy handler made a decision to apply a property-value to the graphic base on the visited resource's data property value.
The files in src/xsl/ns contain variables for all terms in a variety of vocabularies.
<xsl:transform version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xd="http://www.pnp-software.com/XSLTdoc"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:dcterms="http://purl.org/dc/terms/">
<xd:doc type="stylesheet">
<xd:short>Vocabulary terms.</xd:short>
<xd:detail></xd:detail>
<xd:author>Timothy Lebo</xd:author>
<xd:copyright></xd:copyright>
<xd:svnId></xd:svnId>
</xd:doc>
<!-- The namespace itself -->
<xsl:variable name="dcterms" select="'http://purl.org/dc/terms/'"/>
<!-- Terms within the namespace -->
<xsl:variable name="dcterms:rightsHolder" select="concat($dcterms,'rightsHolder')"/>
<xsl:variable name="dcterms:isReferencedBy" select="concat($dcterms,'isReferencedBy')"/>
<xsl:variable name="dcterms:identifier" select="concat($dcterms,'identifier')"/>
<xsl:variable name="dcterms:description" select="concat($dcterms,'description')"/>
<xsl:variable name="dcterms:ALL" select="(
$dcterms:rightsHolder, $dcterms:isReferencedBy, $dcterms:identifier, $dcterms:description
)"/>
</xsl:transform>
Some utilities that the "to" and "from" scripts use.
/vsr/src/xsl/util/atoid.xsl
/vsr/src/xsl/util/bestQNameLabelFor.xsl
/vsr/src/xsl/util/nameFactory.xsl
/vsr/src/xsl/util/ns-precedence.xsl
/vsr/src/xsl/util/rtf-function.xsl
/vsr/src/xsl/util/string-if-true.xsl
/vsr/src/xsl/util/string-variables.xsl
/vsr/src/xsl/util/uri.xsl
/vsr/src/xsl/util/xsd-datatype-abbreviations.xsl
- Done in Example: LOD Cloud Diagram uses linksets.vsr.xsl
- provenanceweb.org's PLD reference graph in
source/provenanceweb-org/dataset/cr-full-dump/version/2014-Apr-17
(done as part of analyzing BTC) reused linksets.vsr.xsl - Disagreement graph in IEEE-VAST-Challenge-2008.
- A 2grph.xsl is written for each concrete graphical format (e.g. svg, graphml, etc.)