Iterations

Example 42.7. Iteration for: browsere5.xsl
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

  <xsl:output doctype-system="about:legacy-compat"
        indent="yes"
        method="xml"
        omit-xml-declaration="no"/>

  <xsl:template match="products">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da">
    <head><title>Test</title></head>
    <body>
    <h1>Products, primary</h1>
    <ol>
      <xsl:for-each select="item[@type='P']">
        <li><xsl:value-of select="."/></li>
      </xsl:for-each>
    </ol>
    </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

Try it!


Just as in regular imperative programming, we may combine iterations with selections. Plz refer to the documentation for further examples.