Access to node values

For access to values the <xsl:value-of> element with its obligatory select attribute is used. The template determines the position in the source tree. The select attribute of the <xsl:value-of> element determines which values are copied into the result tree. For example the access to the name, the content or the attributes of the nodes is possible. When choosing the current node, the . character can be used instead of the element name, which means that the content of the current element is outputted. When choosing attributes, the @ character in front of the attribute name is available. If an element with sub-elements is selected, possible subsequent templates without the call <xsl:apply-templates> are ignored and only the selected textual content is displayed. The following example shows this relation:

The stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
    <xsl:output encoding="iso-8859-1" version="1.0"/>
    <xsl:template match="CollectionOfPoems">
                <xsl:value-of select="."/>
    <xsl:template match="Author">
    <xsl:template match="FirstName">
        <xsl:text> </xsl:text>
    <xsl:template match="LastName">
    <xsl:template match="Title">
    <xsl:template match="Strophe">
    <xsl:template match="Verse">

Browser view of the target document:

Browser view: example - value-of

Exercise 3

Rewrite the above stylesheet with the result that the YearOfPublication attribute of the Poem element is displayed.

> > to the solution of exercise 3


<< back next >>


Copyright © dpunkt.verlag GmbH 2004
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSL-FO in der Praxis" ("XSL-FO in practice") is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

dpunkt.verlag GmbH, Ringstraße 19B, 69115 Heidelberg, fon 06221-14830, fax 06221-148399,