Analyze Nodes with TreeViewer
View nodes in an XML document according to the XPath 1.0 data model.
The XPath 1.0 data model (http://www.w3.org/TR/xpath#data-model) views XML documents as containing seven possible node types:
Root nodes (called the document nodes in the XPath 2.0 data model; see http://www.w3.org/TR/xpath-datamodel/#DocumentNode)
Element nodes
Attribute nodes
Text nodes
Comment nodes
Processing instruction nodes
Namespace nodes
Mike Brown and Jeni Tennison have created several stylesheets, available at http://skew.org/xml/stylesheets/treeview/, that visually represent all seven of the XPath node types. Such tools can be useful when trying to uncover less obvious nodes (namespace or whitespace-only text nodes) or when just learning about the XPath model. These stylesheets allow you to view an XML tree either in ASCII (ascii-treeview.xsl) or in HTML (tree-view.xml with tree-view.css). All three are available in the working directory where you extracted the file archive for the book.
When you apply ascii-treeview.xsl to time.xml using an XSLT processor such as Xalan by using this command:
xalan time.xml ascii-treeview.xsl
it will produce the text tree view of time.xml shown in Example 3-5.
Example 3-5. Output from ascii-treeview.xsl
root |_ _ _comment ' a time instant ' |_ _ _element 'time' | \_ _ _attribute 'timezone' = 'PST' |_ _ _text '\n ' |_ _ _element 'hour' | |_ _ _text '11' |_ _ _text '\n ' |_ _ _element 'minute' | |_ _ _text '59' |_ _ _text '\n ' |_ _ _element 'second' ...