WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 1 (1/4) | WebReference

WebReference.com - Excerpt from Inside XSLT, Chapter 2, Part 1 (1/4)

current pageTo page 2To page 3To page 4

Inside XSLT

Trees and Nodes

When you're working with XSLT, you no longer think in terms of documents, but rather in terms of trees. A tree represents the data in a document as a set of nodes-elements, attributes, comments, and so on are all treated as nodes-in a hierarchy, and in XSLT, the tree structure follows the W3C XPath recommendation (www.w3.org/TR/xpath). In this chapter, I'll go through what's happening conceptually with trees and nodes, and in Chapters 3 and 4, I'll give a formal introduction to XPath and how it relates to XSLT. You use XPath expressions to locate data in XML documents, and those expressions are written in terms of trees and nodes.

In fact, the XSLT recommendation does not require conforming XSLT processors to have anything to do with documents; formally, XSLT transformations accept a source tree as input, and produce a result tree as output. Most XSLT processors do, however, add support so that you can work with documents.

From the XSLT point of view, then, documents are trees built of nodes; XSLT recognizes seven types of nodes:

As you'll see in Chapter 7, you use XPath expressions to work with trees and nodes. An XPath expression returns a single node that matches the expression; or, if more than one node matches the expression, the expression returns a node set. XPath was designed to enable you to navigate through trees, and understanding XPath is a large part of understanding XSLT.

current pageTo page 2To page 3To page 4

Created: September 12, 2001
Revised: September 12, 2001

URL: http://webreference.com/authoring/languages/xml/insidexslt/chap2/1/