ZVON > Graphotron > About
| graphotron | daVinci | vcg | dot | tutorial | download | >> about << |

Miloslav Nic [nicmila@systinet.com]

Graphotron - About

Graphotron is a simple XML language for drawing graphs with XPath.

The inspiration came from a Rick Jellife description of Schematron, problably this one: The Schematron differs in basic concept from other schema languages in that it is not based on grammars but on finding tree patterns in the parsed document.

XML documents are trees and if some kind of intradocument linking is used, they can describe a general graph. It is often said that a good picture is worth of a thousand words and so I have started to look for a way how program something like pictorial Schematron. I have been pleased to find a few very good programs (Graphviz, VCG, daVinci) which have at least some versions freely available. I did some experiments and found out that drawing pictures with XPath can be very simple.

The first version of ZvonGraphotron was almost finished in June, but then I became involved in several other projects (RFC repository being the most time consuming) and so I let it to rest. In Novemeber I finally won a battle with my laziness and started to write the documentation and implement new features absent from the draft version.

The design criteria for Graphotron are simple:

  1. easiness of implementation in XSLT
  2. a minimal number of elements and attributes
  3. easy targeting for indivdual output platform.

Graphotron 1.0 consists of 9 elements, from which only 4 are needed for basic usage. There is also a very simple mechanism to add properties specific to individual display programs.

There was a prize to pay for the high configurability. The stylesheets does not conform to the XSLT 1.0 constraints on result tree fragments. These constraints will be lifted from XSLT 2.0, and there is at least one implementation, Saxon, which is freely available.

A graph consists of vertices, edges and so the basic elements of Graphotron are vertex and edge.

Vertices are created from the nodes of the XML document (elements, attributes, text-nodes, ...) and the nodes to be used are specified by an absolute XPath in match attribute of the element. The number of vertex elements is not restricted. If a node is matched by several vertex elements, the last matching vertex is used.

Edges are specified with the edge element. It has two attributes: match and select. The match attribute selects starting vertex, the select attribute the target vertex. Only edges between vertices selected by vertex elements are used.

Graph drawing programs use different conventions to specify properties of vertices and edges. Graphotron uses following mechanism to address individual applications:

Inside Graphotron vertex and edge elements the individual properties can be specified using elements from application dependent namespace. The name of element is derived from the property name of the target application. Its value can be extracted from the source XML document or set in Graphotron file.

An example:

In VCG program, color of the vertex label is set by textcolor property. ZvonGraphotron implementation introduces a namespace for VCG: xmlns:vcg="http://zvon.org/graphotron/vcg" and the color can be set e.g. as: <vcg:textcolor>red</vcg:textcolor> or <vcg:textcolor select="@color"/>. In this way, if there is a new version of the graph drawing program available, properties introduced in this new version can be immediately used without changing the Graphotron implementation.

Consult following materials, containing many examples, for more information: