Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Sequences (1/10) >

Sequences and comma operator

In XSLT 2.0 sequences of numbers, strings or nodes can be created with the comma operator.

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="/aaa">
                  <xxx>
                        <xsl:value-of  select="1,2,3,4"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="'a','b','c','d'"/>
                  </yyy>
                  <yyy>
                        <xsl:value-of  select="bbb[3],bbb[1],bbb[2]"/>
                  </yyy>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa>
            <bbb>b1</bbb>
            <bbb>b2</bbb>
            <bbb>b3</bbb>
      </aaa>
Output

      <xxx>1 2 3 4</xxx>
      <yyy>a b c d</yyy>
      <yyy>b3 b1 b2</yyy>


Previous chapter: Templates - basic usage
Next chapter: Sequence Combinations
Previous page: - - -
Next page: Sequences of several types