<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="4.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:fn="http://www.w3.org/2005/xpath-functions"
  xmlns:map="http://www.w3.org/2005/xpath-functions/map"
  xmlns:math="http://www.w3.org/2005/xpath-functions/math"
  xmlns:array="http://www.w3.org/2005/xpath-functions/array"
  xmlns:tm="http://www.datenverdrahten.de/tm"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="#all"
  expand-text="yes">

  <!-- by T. Meinike 11/22 -->

  <xsl:output method="xml" version="1.0" html-version="5" encoding="UTF-8"
    indent="yes" include-content-type="no" omit-xml-declaration="yes"/>

  <xsl:template name="xsl:initial-template">

    <xsl:text disable-output-escaping="yes">&lt;!DOCTYPE html>&#xA;</xsl:text>
    <html lang="de">
      <head>
        <meta charset="UTF-8"/>
        <title>Iteration über Arrays und Maps</title>
        <style>
          * {{ font-family: sans-serif; }}
          p {{ font-weight: bold; }}
        </style>
      </head>
      <body>
        <h1>Iteration über Arrays und Maps</h1>
        <!-- The three instructions xsl:for-each, xsl:iterate, and xsl:for-each-group can take an attribute array or map in place of the select attribute. -->
        <!-- lookup expressions ?value / ?key -->

        <p>
          <xsl:for-each array="[3, 9, 1, 7, 5]" separator=" | ">
            <xsl:sort select="?value" order="ascending"/> <!-- value-Sortierung bei Arrays -->
            {?value * 2}
          </xsl:for-each>
        </p>

        <p>
          <xsl:for-each array="[1 to 5, 9 to 17, 1 to 100]" separator=" | ">
            {fn:sum(?value)}
          </xsl:for-each>
        </p>

        <p>
          <xsl:for-each map="map{'a': 789, 'b': 456, 'c': 123}" separator=" | ">
            <xsl:sort select="?key" order="descending"/> <!-- key/value-Sortierung bei Maps -->
            {?value}
          </xsl:for-each>
        </p>
      </body>
    </html>

  </xsl:template>

</xsl:stylesheet>