With the basics of template rules and selection down, let's look at some ways to customize the process. This section covers node creation, generating numbers and text, and sorting and looping through node sets.
The default rule for elements and attributes is to output the contents as text. So far, we have no other way of outputting the values of nodes. <xsl:value-of> is the tool for calculating and returning values. To see how it works on nodes, consider the following rule:
<xsl:template match="source"> <xsl:value-of select="."/> </xsl:template>
If we turn this rule loose on the <quotelist> example, we get this result:
publication The New Scientist 6/99 tv-show Homer The Simpsons Greg Travis Confucius
The values for each type of node are calculated as follows:
The root node inherits the value of the document element.
All the parsed character data in the element, together with the values of its descendants.
The value of the attribute with entities resolved, and leading and trailing whitespace removed.
All the text in the node.
Everything inside the processing instruction delimiters except the name.
The text inside the comment delimiters.
The namespace's URI.
If <xsl:value-of> is applied to a node set, only the first node's value is used. We might be tempted to use the following rule, but it would return only the value of the first ...