XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / Stylesheets with multiple templates / Delegating: a template rule for addresses
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
What should we do? First, define a separate processing rule for addresses, in other words a template rule intended for these elements. It must contain the required <p> container as a literal result element (LRE), with a xsl:value-of instruction that uses select="." to extract the string value of the address currently being processed, which is then the context node:
<!-- Template-Regel für <adresse>: -->
<xsl:template match="adresse">
<!-- hier werden <adresse>-Elemente verarbeitet: -->
<p><xsl:value-of select="."/></p>
</xsl:template>
Code example: kap01/1.15.3/adressen.xsl (excerpt).
This template rule is activated whenever an element <adresse> is offered to the processor for processing. So far, so good. For now, however, the context remains (immovably?) on the document node. How can we get the XSLT processor to process the elements <adresse> and, above all, in sequence? To do this, the second template rule must be called from the current template rule.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn