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

Several variables can be used is "for ... in ... return" instruction

Several variables can be specified at once using multiple "in" parts.

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="for $a in (1 to 3), $b in (1,10,100) return $a * $b"/>
                  </xxx>
                  <yyy>
                        <xsl:value-of  select="for $a in ('a','b'), $b in ('c','d'), $c in ('e','f','g') return concat($a,$b,$c)"/>
                  </yyy>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <xxx>1 10 100 2 20 200 3 30 300</xxx>
      <yyy>ace acf acg ade adf adg bce bcf bcg bde bdf bdg</yyy>


Previous chapter: Templates - basic usage
Next chapter: Sequence Combinations
Previous page: Creation of sequences using for ... in ... return instruction
Next page: Instruction xsl:sequence