Schema Navigator
Contact: pickard.matthew@gmail.com
Schema Navigator
The idea of the navigator is to make it easier to get a feel for XML documents. At the moment it can
understand most W3C schema and Document Type Definitions. In the future I'd also like to be able to render Relax-NG.
The navigator is not an editor, nor does it give you strictly accurate view of the document's low level
components and compositors. So in the case of a document specified using W3C Schema the cardinality,
choice/sequence/... information is lost. I hope application gives you insight into a document's structure by showing
you its gross properties. For example if you are developing an XSLT stylesheet you'd be interested in a particular
element's lineage. You may want an idea of all the contexts in which an element might occur.
Here are a couple of examples showing the kinds of things I have in mind.
Examples
XSLT2
The W3C Schema XSLT 2 has been rendered here. You can see that the layout algorithm has organised the
graph into two clusters. It happens that the each clusters correspond to a distinct namespace, which is indicated by
the colour. The mauve elements belong to XSLT2 and the blue ones to W3C Schema.
You can see the namespace partitions the model very neatly. It is obvious that there are virtually no
interrelationships between elements of the two domains. One that describes how a stylesheet works and the other how to
describe an XML language. As XSLT2 may be schema aware it has the means of linkage. The point of contact as you can see
in the centre of the diagram. It's the element import-schema, which can reference or physically contained the a
schema.
XSLT2 with Meyer's self-organizing graph
Although the layout engine has no sense of the schema's type system or internal organisation it is fun to
play around with different algorithms and see what is thrown up. After a bit of shuffling about I came across this. It
is a very symmetrical arrangement which confines the 21 or so elements that derive from XSLT's 'sequence constructor'
to a very small section of the graph (highlighted in green). It shows that the cluster has an almost identical
relationship with the following elements that are arranged about it; apply-imports, apply-templates, sequence and
call-template.
Circularity
Looking closely at the XSLT element-constructor and its immediate relations pattern is discernible. Colour
highlight indicates a relation; green self, blue child, red parent, and mauve parent-or-child. There are a large number
of interdependencies and circularity confined to this part of the graph. You can compose XSLT instructions in may ways.
So may be this is an indication of flexibility?
Composability - Circular Languages Flexibility
Maths Markup Language
I don't know anything about this language but with the tool I can see it has about 180 elements and nearly
7000 links. That's almost that is almost as many links as it could have so it must be very circular. Maybe that
indicates that it too is composable and flexible?.
Looking at relations it seems that the structure is fairly straightforward, there is a core of a elements
surrounded by a sort of corona of others. All of the elements in the core can be parent to one and another, while the
surrounding ones can only be children.
Here are a few more examples of languages which have this controlled composablility aspect. The first one
is the XSL Formatting Object specification. The next picture came from the XHTML Schema. Although I think this digram
more complicated than it needs to be. I have seen similar structures where this kind of complexity can be hidden with
the careful use of substitution groups. For example there are a lot of inline elements that can occur in the same
context and have similar content models.
XSL FO
XSL Formatting Objects and HTML seem to describe very similar structures. Both have tables and lists, and
section like elements that can be composed into hierarchies, and in-line or spanning elements.
XHTML
A more linear document MS WordML
This diagram has a very different kind of feel. There are a lot of elements (500) and relatively few
relations (700). So I guess, notwithstanding the number of elements, the number of possible structures is relatively
constrained. So taking two points in the graph you would find relatively few paths connecting them as opposed to XHTML
where there may be infinitely many.
Installing
Java 6 required.
Optionally Saxonica v 9
Memory requirements should not be excessive.
You can use Sun's native schema processing API or if you have Saxonica you can use that API instead.
If you go for the first option, on some systems you make user the JDK tools lib is visible..
set CP=%CP%;%JAVA_HOME%\lib\tools.jar
If you have a licensed version of Saxon 9 Schama Aware processor you can use that instead of the native Java XSOM libs in tool.jar. You need to make sure the net.gialine.modnav.USE_SAXON system property is set in the start up scripts.
- In the script set the property -Dnet.gialine.modnav.USE_SAXON=yes
- Either update the script's classpath parameter or copy the Saxonica license file to the Navigator's install directory.
- Either update the script's classpath parameter or copy the Saxonica jar file to the Navigator's install/lib directory.
Using Schema Navigator
Once you figure out how to open a new file the navigator will need to know a few things. If you are looking at the schema then there may be some namespaces. The application allows you to enter your preferred prefix mappings along with colours that will be used in the final display.
Namespace Preference Dialog
Initially the pop-up dialogue will show some defaults for the namespace prefixes. Please override these as you see fit but they should be unique. If you click on a colour another dialogue comes up allowing you to choose from a palette. Subdued colours are better otherwise the final diagram may will look crowded. The application will remember your preferences for the future, but may still override them at start-up. Select okay.
Root Element Selection
To explore the document navigator needs a starting point. To the left along with their (new) prefix mappings will be a list of top-level elements. Choose the one which usually acts as a document or root element. At the moment the application is still experimental please leave abstract elements checked and select expand substitutions. Ignore coalesce names. Again select okay.
Final Diagram-With Name Dialogue
If all went well you should be looking at the diagram like the one above. To render a model like this should only take a second or two at most. For example XHTML takes a little under a second on a dual core 2.8 MacBook Pro and maths are now just under two. For very dense graphs some layouts take a little longer to settle than others. Alternative layouts may be selected from the menu or the operating system dependent shortcut keys.
Change
The right-hand inspector panel is no longer part of the main screen. To see it choose it from the menu or press you OS specific alt+(n/t/r) keys.
One you have a graph you can interact with it. There are three operational tabbed panels to the right of the screen. By default the name choosers selected. If you pick an element in the main diagram with your mouse it will highlight along with any other elements that share its name, and the panel list will be updated. Likewise selecting an element from the list will highlight the corresponding node(s) in the graph. In the above example, which is displaying the W3C Schema, the element xs:element has been clicked, and oddly enough it seems there are three... Indeed there are. You can check yourself.
Exploring the Types
You may want to explore the type system behind the model. On the right-hand side select the model tab. Now you should see a list of global types have been declared in the schema. You can filter that list so that only complex or simple types of visible. You can also choose whether the application performs a deep compere when it inspects each element. This is in respect of the scheme is type system. So if type B inherits from a selecting type a will also highlight elements of type B. Again you can choose from either the graph or the panel to select the type
The Relationship Explorer
You can also examine relationships between elements. Select the relations type. The panel on the right has a number of components. First there was a drop-down box which selects the element to examine. Next is children and parents are listed. Items therein are selectable. The bottom half of the panel displays information about the element. Its main namespace content model, or rather its type. The number of inwardly directed edges and outward. Its attributes are also listed. As usual selecting an element highlighted in green. Its parents in red and its children the colour blue. Elements which can be both parent and child are highlighted in purple. When you travel from related elements your path is traced and highlighted in white when more related elements are selected for their relationships the elements on the current path are also highlighted. Selecting an unrelated element clears path.