SHOWTREE - XSLT Tree Display Stylesheet

These stylesheets expose the node structure created by an XSLT engine for a given instance.

The stylesheet will report the node structure and content of an input document, noting the ordinal positions in the hierarchy of each component of the ancestry.

The stylesheet can expose all nodes of all types, but is configured by default to not access the namespace axis. Some tools (e.g.: XT) do not allow access to the namespace axis. Other tools (e.g.: Saxon) do allow access to the namespace axis. The documentation inside the stylesheet describes which lines to remove to engage access to the namespace axis.

The stylesheet for the current W3C XSLT/XPath 1.0 Recommendations can be obtained from: http://www.CraneSoftwrights.com/resources/showtree/showtree-20000610.xsl. It has been tested unmodified on XT (version 19991105) and modified as documented to report namespaces on Instant Saxon (version 5.3.2). The stylesheet was last modified 2000-06-10.

The stylesheet for the original Microsoft IE5 can be obtained from: http://www.CraneSoftwrights.com/resources/showtree/showtree-19990409.msxsl. It has been tested on IE5 Version 5.00.2014.0216. The stylesheet was last modified 1999-04-09 09:20.

The following session illustrates an example of output from the use of both the unmodified and modified stylesheet on the same XML file. Note the XML file is directly viewable from Internet Explorer 5 because of the embeeded stylesheet association processing instruction. When running the stylesheet from the DOS command line the stylesheet association processing instruction isn't acted upon, thus allowing any file to be examined with these diagnostic stylesheets.



T:\ftemp>type model.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="showtree.msxsl"?>
<!--comment number 1-->
<model
  pub-id="+//ISBN 1-894049::CSL::Samples::SHOWTREE//Document SHOWTREE Test//EN"
  attr2="Value of second attribute"
  attr3="attr3">
<title test="value">A Course with <emph>mixed</emph> content</title>
<toc id="toc"/>
<!--comment number 2-->
<ext-links id="extlinks"/>
<?pi2 value of pi2?>
<prelude id="index" xmlns:abc="http://abc">
<tpane>
<ttitle><abc:line>Presentation</abc:line><line>Test</line></ttitle>
<?test a test processing instruction?>
<stitle><line>Presentation</line><line>Subtitle</line></stitle>
<emptyTest/>
</tpane>
</prelude>

</model>
T:\ftemp>xt model.xml showtree.xsl model-subset.txt

T:\ftemp>type model-subset.txt
SHOWTREE Stylesheet - http://www.CraneSoftwrights.com/resources/
Processor: James Clark
1  Proc. Inst. 'xml-stylesheet': {type="text/xsl" href="showtree.msxsl"}
2  Comment: {comment number 1}
3  Element 'model':
3.A  Attribute 'pub-id': 
{+//ISBN 1-894049::CSL::Samples::SHOWTREE//Document SHOWTREE Test//EN}
3.B  Attribute 'attr2': {Value of second attribute}
3.C  Attribute 'attr3': {attr3}
3.1  Text (model): {
}
3.2  Element 'title' (model):
3.2.A  Attribute 'test': {value}
3.2.1  Text (model,title): {A Course with }
3.2.2  Element 'emph' (model,title):
3.2.2.1  Text (model,title,emph): {mixed}
3.2.3  Text (model,title): { content}
3.3  Text (model): {
}
3.4  Element 'toc' (model):
3.4.A  Attribute 'id': {toc}
3.5  Text (model): {
}
3.6  Comment (model): {comment number 2}
3.7  Text (model): {
}
3.8  Element 'ext-links' (model):
3.8.A  Attribute 'id': {extlinks}
3.9  Text (model): {
}
3.10  Proc. Inst. 'pi2' (model): {value of pi2}
3.11  Text (model): {
}
3.12  Element 'prelude' (model):
3.12.A  Attribute 'id': {index}
3.12.1  Text (model,prelude): {
}
3.12.2  Element 'tpane' (model,prelude):
3.12.2.1  Text (model,prelude,tpane): {
}
3.12.2.2  Element 'ttitle' (model,prelude,tpane):
3.12.2.2.1  Element '{http://abc}abc:line' (model,prelude,tpane,ttitle):
3.12.2.2.1.1  Text (model,prelude,tpane,ttitle,abc:line): {Presentation}
3.12.2.2.2  Element 'line' (model,prelude,tpane,ttitle):
3.12.2.2.2.1  Text (model,prelude,tpane,ttitle,line): {Test}
3.12.2.3  Text (model,prelude,tpane): {
}
3.12.2.4  Proc. Inst. 'test' (model,prelude,tpane): {a test processing instruction}
3.12.2.5  Text (model,prelude,tpane): {
}
3.12.2.6  Element 'stitle' (model,prelude,tpane):
3.12.2.6.1  Element 'line' (model,prelude,tpane,stitle):
3.12.2.6.1.1  Text (model,prelude,tpane,stitle,line): {Presentation}
3.12.2.6.2  Element 'line' (model,prelude,tpane,stitle):
3.12.2.6.2.1  Text (model,prelude,tpane,stitle,line): {Subtitle}
3.12.2.7  Text (model,prelude,tpane): {
}
3.12.2.8  Element 'emptyTest' (model,prelude,tpane):
3.12.2.9  Text (model,prelude,tpane): {
}
3.12.3  Text (model,prelude): {
}
3.13  Text (model): {

}
T:\ftemp>saxon -o model-all.txt model.xml showtree-modified.xsl

T:\ftemp>type model-all.txt
SHOWTREE Stylesheet - http://www.CraneSoftwrights.com/resources/
Processor: SAXON 5.3.2 from Michael Kay of ICL
1  Proc. Inst. 'xml-stylesheet': {type="text/xsl" href="showtree.msxsl"}
2  Comment: {comment number 1}
3  Element 'model':
3.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.A  Attribute 'pub-id': 
{+//ISBN 1-894049::CSL::Samples::SHOWTREE//Document SHOWTREE Test//EN}
3.B  Attribute 'attr2': {Value of second attribute}
3.C  Attribute 'attr3': {attr3}
3.1  Text (model): {
}
3.2  Element 'title' (model):
3.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.2.A  Attribute 'test': {value}
3.2.1  Text (model,title): {A Course with }
3.2.2  Element 'emph' (model,title):
3.2.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.2.2.1  Text (model,title,emph): {mixed}
3.2.3  Text (model,title): { content}
3.3  Text (model): {
}
3.4  Element 'toc' (model):
3.4.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.4.A  Attribute 'id': {toc}
3.5  Text (model): {
}
3.6  Comment (model): {comment number 2}
3.7  Text (model): {
}
3.8  Element 'ext-links' (model):
3.8.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.8.A  Attribute 'id': {extlinks}
3.9  Text (model): {
}
3.10  Proc. Inst. 'pi2' (model): {value of pi2}
3.11  Text (model): {
}
3.12  Element 'prelude' (model):
3.12.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.II  Namespace 'abc': {http://abc}
3.12.A  Attribute 'id': {index}
3.12.1  Text (model,prelude): {
}
3.12.2  Element 'tpane' (model,prelude):
3.12.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.II  Namespace 'abc': {http://abc}
3.12.2.1  Text (model,prelude,tpane): {
}
3.12.2.2  Element 'ttitle' (model,prelude,tpane):
3.12.2.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.2.II  Namespace 'abc': {http://abc}
3.12.2.2.1  Element '{http://abc}abc:line' (model,prelude,tpane,ttitle):
3.12.2.2.1.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.2.1.II  Namespace 'abc': {http://abc}
3.12.2.2.1.1  Text (model,prelude,tpane,ttitle,abc:line): {Presentation}
3.12.2.2.2  Element 'line' (model,prelude,tpane,ttitle):
3.12.2.2.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.2.2.II  Namespace 'abc': {http://abc}
3.12.2.2.2.1  Text (model,prelude,tpane,ttitle,line): {Test}
3.12.2.3  Text (model,prelude,tpane): {
}
3.12.2.4  Proc. Inst. 'test' (model,prelude,tpane): {a test processing instruction}
3.12.2.5  Text (model,prelude,tpane): {
}
3.12.2.6  Element 'stitle' (model,prelude,tpane):
3.12.2.6.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.6.II  Namespace 'abc': {http://abc}
3.12.2.6.1  Element 'line' (model,prelude,tpane,stitle):
3.12.2.6.1.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.6.1.II  Namespace 'abc': {http://abc}
3.12.2.6.1.1  Text (model,prelude,tpane,stitle,line): {Presentation}
3.12.2.6.2  Element 'line' (model,prelude,tpane,stitle):
3.12.2.6.2.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.6.2.II  Namespace 'abc': {http://abc}
3.12.2.6.2.1  Text (model,prelude,tpane,stitle,line): {Subtitle}
3.12.2.7  Text (model,prelude,tpane): {
}
3.12.2.8  Element 'emptyTest' (model,prelude,tpane):
3.12.2.8.I  Namespace 'xml': {http://www.w3.org/XML/1998/namespace}
3.12.2.8.II  Namespace 'abc': {http://abc}
3.12.2.9  Text (model,prelude,tpane): {
}
3.12.3  Text (model,prelude): {
}
3.13  Text (model): {

}
T:\ftemp>rem end

If anyone has comments on these stylesheets, they are welcome to send them to showtree@CraneSoftwrights.com.

For more information regarding XSLT, a free preview download of Crane's commercial XSLT training material can be obtained from http://www.CraneSoftwrights.com/training/.

See also Mike Brown's Fancy XML Tree Viewer that produces a colourful table-based HTML display of the nested hierarchies in an XML document.

Crane logo
CRANE
SOFTWRIGHTS
LTD.
 TRAINING RSS XML 
 RESOURCES RSS XML 

Please consider to


towards our
free resources.

+1 (613) 489-0999 (Voice)
+1 (613) 489-0995 (Fax)

info@CraneSoftwrights.com


Link traversal: This web site relies heavily on client-side redirection. If certain links do not work for you, please ensure you have this behaviour enabled in your browser.

Site navigation:

Small print: All use of this web site and all business conducted with Crane Softwrights Ltd. is subject to the legal disclaimers detailed at http://www.CraneSoftwrights.com/legal ... please contact us if you have any questions. All trademarks, servicemarks, registered trademarks, and registered servicemarks are the property of their respective owners.

Link legend: links that are marked with this dotted underline will open up a new browser window, otherwise the same browser window is used for the link target. 

Last changed: $Date: 2006/12/27 20:32:19 $(UTC) (Privacy policy)