XQuery/Graphing Triples

The RDF Validation service can be used to graph RDF, but since this expands prefixed names to full URIs the graphs can look rather un-readable as examples.

This service is for drawing simple triple graphs where each triple is defined in a local XML format in which each triple has attributes subject, property and object. [XQuery function to convert RDF to N3 needed]

Subjects and objects are drawn as nodes, triples as arcs with the property as the label. If the subject or object contains ':' or starts with 'http://', then the node is shown as an ellipse. If it starts with '_' it is a blank node and an unnamed circle is shown; otherwise the node is assumed to be a literal and is drawn in a box.

Parameters

 * url : url of triples in the xml format illustrated above
 * dir : LR - left to right (default), TB - top to bottom [ rankdir in Graphviz]
 * title : title for graph - default none

Example
From page 11 of the RDF primer

     

dot Output

digraph { rankdir='LR' "exstaff:85740" [label="exstaff:85740" shape=ellipse]; "exaddressid:87540" [label="exaddressid:87540" shape=ellipse]; "1501 Grant Avenue" [label="1501 Grant Avenue" shape=box]; "Bedford" [label="Bedford" shape=box]; "Massachusetts" [label="Massachusetts" shape=box]; "01730" [label="01730" shape=box]; "exstaff:85740" -> "exaddressid:87540" [label="exterms:address"]; "exaddressid:87540" -> "1501 Grant Avenue" [label="exterms:street"]; "exaddressid:87540" -> "Bedford" [label="exterms:city"]; "exaddressid:87540" -> "Massachusetts" [label="exterms:state"]; "exaddressid:87540" -> "01730" [label="exterms:postalcode"]; }

GIF Image

http://www.cems.uwe.ac.uk/~cjwallac/apps/services/dot2media-v2.php?url=http://kitwallace.co.uk/rdf/xquery/triple2dot.xq?url%3Dhttp://kitwallace.co.uk/rdf/data/triplesExample.xml

Usage
Either save the generated gif, or use 5clicks or similar to capture the image on the screen. One way to print large GIF images is to save the image, then insert it into an Excel spreadsheet. Excel will print the image over multiple pages. Reduced in size and with page borders removed, even large graphs can be printed and then taped together.

Source
This script would be improved by the use of an intermediate XML structure and a XSLT script to convert to dot.