Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Value-of (2/6) >

Separators between text nodes generated by value-of

If xsl:value-of element matches several nodes, an optional attribute separator can be used to specify characters for inclusion between individual text nodes.

XSLT

      <xsl:stylesheet
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:template  match="/">
                  <xxx>
                        <xsl:value-of  select="/aaa/bbb"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="/aaa/bbb"
                                    separator="-"/>
                  </yyy>
                  <zzz>
                        <xsl:value-of  select="/aaa/bbb"
                                    separator="=!!="/>
                  </zzz>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>How</bbb>
            <bbb>do</bbb>
            <bbb>you</bbb>
            <bbb>do?</bbb>
      </aaa>
Output

      <xxx>How do you do?</xxx>
      <yyy>How-do-you-do?</yyy>
      <zzz>How=!!=do=!!=you=!!=do?</zzz>


Previous chapter: Sequence Combinations
Next chapter: Modes
Previous page: Implicit inclusion of space character
Next page: Numbers and separators