Getting the Content of an Element

As you scan down Listing 2.3, you’ll see the first XSLT element, <xsl:value-of>. The purpose of the <value-of> element is to retrieve the content from an element or an attribute. The <value-of> element takes an optional select attribute and a pattern (or location path) that allows you to specify a node or collection of nodes from which to get content. In this case, Listing 2.3 uses <xsl:value-of select="invoice/clientName"> to grab the content from the <clientName> element in the source tree and insert it into the result tree.

In constructing the pattern, you’ll notice that the step pattern does not contain a beginning slash to tell the processor to begin its search at the root node. The reason is that the template ...

Get Special Edition Using XSLT now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.