W3C SW Dev

Circles and arrows diagrams using stylesheet rules

One of the objectives of the advanced development component of the Semantic Web activity is to demonstrate how RDF and Semantic Web technologies can be applied to the W3C Process to increase efficiency, reliability, etc. In the early stages of developing an RDF model of the W3C process, the tools I was using to visualize the model while working on it started working well enough that I started applying them to all sorts of stuff.

Starting with the open source graphviz toolset from AT&T research, we model the structure of its .dot input files using an RDF vocabulary of terms like digraph, hasNode, EdgeProperty, etc.; an XSLT transformation, rdf2dot.xsl, produces actual .dot syntax from RDF/xml documents that use this vocabulary. This vocabulary is documented* in gv.n3 (using a sort of wiki RDF syntax; cf. Primer: Getting into RDF & Semantic Web using N3).

* to some extent; I'm afraid the gv schema is incomplete and the XSLT code is the only complete reference as of this writing. The gv vocabulary does follow Drawing graphs with dot quite closely, though, and tracks updates to dot graph attributes to some extent.

Try it

Using our interactive XSLT service:

XSL file:

XML data:

Diagram Style Rules

Now for the fun part: exploiting generic RDF rules processing to deduce facts about graphviz diagrams from facts built from other vocabularies. Suppose we know a few simple facts:

In our wiki RDF syntax, we can write this as:

:w :staff :d .
:d a :Person; :name "Dan Connolly".
:w a :Organization; :tla "W3C".

If you're more familiar with the XML syntax for RDF, that's:

            <Organization rdf:about="#w">
                  <Person rdf:about="#d">
                    <name>Dan Connolly</name>

Now let's represent that in circles-and-arrows. First, we'll say that staff properties should be drawn as arrows, labelled "Technical Staff":

:onStaff a g:EdgeProperty; g:label "Technical Staff".


            <g:EdgeProperty rdf:about="#staff">
                <g:label>Technical Staff</g:label>

Now for the rules bit: if something is a person whose name is some string, then use that string as the label for the thing in the diagram:

this log:forAll :n, :str.

{ :n a :Person; :name :str } log:implies { :n g:label :str }.

I hope you don't mind if I leave the RDF/XML syntax for rules for another day... Let's look at one more rule though: if something is an organization with some string as its TLA, then label it with that string, make it 20pt white text on a blue background:

{ :n a :Organization; :tla :str }
 log:implies { :n g:label :str;
		g:style "filled";
		g:color "blue";
		g:fontcolor "white";
		g:fontsize "20" }.

Then we put that into cwm, our rules engine, and ask it to think; i.e. apply all the rules over and over until no new conclusions come out:

  python cwm.py sw-bcard.n3 --think --rdf> sw-bcard.rdf

If you look inside sw-bcard.rdf, you'll see that cwm concluded that Dan's name is also his graphic label, and that W3C is blue etc.

Then we feed sw-bcard.rdf thru rdf2dot.xsl and out comes dot syntax; from there, we use the graphviz tools to produce SVG, PNG, postscript, and the other formats supported by graphviz. And that's all there is to it.**

**Actually, there are a few limitations you should know about. rdf2dot.xsl only groks a subset of RDF syntax, so you need to use a few more cwm flags to keep the nesting to a minimum and absolutize all URI references. See the Makefile for details

More Examples

These are some of the first few examples I worked on; they might be out of date in some details:

RDF/n3 transcription of graphviz/dot vocabulary; test-graph1.n3 is an example; rdf2dot.xsl writes takes RDF/XML syntax and writes dot syntax; see the Makefile for details. (@@discuss partial understanding)
a stylesheet for drawing a sort of audit diagram; rec54.{n3,rdf} is a model of the W3C Recommendation process; rec54-img.{n3,rdf,dot,ps,svg,png} is a diagram using this style; note that the RDF is generated using cwm.py -think (@@explain more). I started working on this example by drawing rec22.dot by hand (ps output). rec54 hasn't yet caught up with rec22 in the level of detail.

see also: PaperTrail, Conversations and State, INDECS stuff@@

a stylesheet for drawing organization diagrams for W3C: domains/activities/groups, chairs, etc.; swa2.{n3,rdf,dot,ps} is represents the structure from the Semantic Web Activity statement. swa.{dot,ps}, rk43.{dot,ps}, and swad.{dot,ps} are hand-edited predecessors of swa2.dot.
prop43.n3 and kpic.n3
a re-creation of the circles-and-arrows diagram from the original 1989 WWW proposal; output is proposal1989.{rdf,dot,svg,ps}.
see also: danbri's rendition, Sep 2000 discussion
some rules about subClass, subProperty, etc.

I'd like to revisit my March 2000 work on XML spec dependencies and Feb 2000 issue resolution process diagrams, now that I have these tools.

note to self: CirclesAndArrowsDiagrams in one of my Feb 2001 test wikis.

Related work

See also SiRPAC, rdfviz.

Getting the source code

All semantic web development is supposed to be done in a world-readable CVS repository, per the Semantic Web Activity statement. So this stuff should perhaps be moved near telagent/palmagent.

But for now, you should be able to just follow the links to each of the bits. Sorry about that.

Dan Connolly
$Revision: 1.17 $ of $Date: 2005/11/17 15:13:00 $ by $Author: connolly $