showtree.xsl - Exposing the Node Structure of an Instance


Date:      Tue, 19 Jan 1999 16:21:17 -0500
From:      "G. Ken Holman" <gkholman@CraneSoftwrights.com>
To:        XSL List <xsl-list@mulberrytech.com>
Subject:   Ann: showtree.xsl - Exposing the node structure of an instance

showtree.xsl - Exposing the node structure of an instance

This stylesheet showtree.xsl is useful for learning the node structure created by an XSL engine for a given instance. It has been tested on XT 19990115 as matching the 19981216 working draft.

This 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.

This stylesheet exposes root, element, attribute, text, comment, and pi nodes.

This stylesheet does not (cannot?) expose the namespace nodes (only other kinds of node).

For example, given the XML instance:


<?xml version="1.0"?>
<?pi1 value of pi1?>
<!--comment number 1-->
<greeting
  pub-id="+//ISBN 1-894049::CSL::Samples::SHOWTREE//Document SHOWTREE
Test//EN"
  attr2="Value of second attribute">
<purpose>To convey a greeting</purpose>
<test1>A test<test2>of depth<test3>to three levels</test3></test2></test1>
<!--comment number 2-->
<prelude id="start" xmlns:info="http://www.CraneSoftwrights.com/resources/">
<?pi2 value of pi2?>
<info:detail>Information about Greeting</info:detail>
</prelude>
<value>Hello world!</value>

</greeting>

The resulting output is as follows (note that mailers may interfere with
the display of long lines below):

SHOWTREE Stylesheet - http://www.CraneSoftwrights.com/resources/
Root:
1  Proc. Inst. 'pi1' (root): {value of pi1}
2  Comment (root): {comment number 1}
3  Element 'greeting' (root):
3.1  Attribute 'pub-id' (greeting): {+//ISBN
1-894049::CSL::Samples::SHOWTREE//Document SHOWTREE Test//EN}
3.2  Attribute 'attr2' (greeting): {Value of second attribute}
3.3  Text (greeting): {
}
3.4  Element 'purpose' (greeting):
3.4.1  Text (greeting,purpose): {To convey a greeting}
3.5  Text (greeting): {
}
3.6  Element 'test1' (greeting):
3.6.1  Text (greeting,test1): {A test}
3.6.2  Element 'test2' (greeting,test1):
3.6.2.1  Text (greeting,test1,test2): {of depth}
3.6.2.2  Element 'test3' (greeting,test1,test2):
3.6.2.2.1  Text (greeting,test1,test2,test3): {to three levels}
3.7  Text (greeting): {
}
3.8  Comment (greeting): {comment number 2}
3.9  Text (greeting): {
}
3.10  Element 'prelude' (greeting):
3.10.1  Attribute 'id' (greeting,prelude): {start}
3.10.2  Text (greeting,prelude): {
}
3.10.3  Proc. Inst. 'pi2' (greeting,prelude): {value of pi2}
3.10.4  Text (greeting,prelude): {
}
3.10.5  Element 'http://www.CraneSoftwrights.com/resources/#info:detail'
(greeting,prelude):
3.10.5.1  Text
(greeting,prelude,http://www.CraneSoftwrights.com/resources/#info:detail):
{Information about Greeting}
3.10.6  Text (greeting,prelude): {
}
3.11  Text (greeting): {
}
3.12  Element 'value' (greeting):
3.12.1  Text (greeting,value): {Hello world!}
3.13  Text (greeting): {

}

The stylesheet can be obtained from the resources link below.

.............. Ken



G. Ken Holman         mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.  http://www.CraneSoftwrights.com/s/
Box 266,                                V: +1(613)489-0999
Kars, Ontario CANADA K0A-2E0            F: +1(613)489-0995
Training:   http://www.CraneSoftwrights.com/s/schedule.htm
Resources: http://www.CraneSoftwrights.com/xs/resources2.htm

Shareware: http://www.CraneSoftwrights.com/s/shareware.htm
Next XSL Training (see training link):   WWW8 - 1999-05-11

XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list