<?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:saxon="http://saxon.sf.net/"  
  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>New Functions</title>
        <style> * {{ font-family: sans-serif; }} </style>
      </head>
      <body>
        <h1>New Functions</h1>

        <!-- Numbers -->
        <p>fn:is-NaN(123): {fn:is-NaN(123)}</p> <!-- false -->
        <p>fn:is-NaN("abc"): {fn:is-NaN(fn:number("abc"))}</p> <!-- true -->
        <p>fn:is-NaN(math:sqrt(-1): {fn:is-NaN(math:sqrt(-1))}</p> <!-- true -->

        <!-- Strings -->
        <p>fn:characters("Hallo Welt!"): {fn:characters("Hallo Welt!")}</p>
          <!-- ("H", "a", "l", "l", "o", " ", "W", "e", "l", "t", "!") -->

        <!-- Higher-Order Functions -->
        <p>fn:some((1, 2, 3), ->{{. mod 2 = 0}}): {fn:some((1, 2, 3), ->{. mod 2 = 0})}</p> <!-- true -->

        <p>fn:some(("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"), contains(?, "n")):
          {fn:some(("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"), contains(?, "n"))}</p>
          <!-- true -->

        <p>fn:all((1, 2, 3), ->{{. mod 2 = 0}}): {fn:all((1, 2, 3), ->{. mod 2 = 0})}</p> <!-- false -->

        <p>fn:all(("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"), contains(?, "n")):
          {fn:all(("Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"), contains(?, "n"))}</p>
          <!-- false -->

        <!-- fn:range() in Saxon 11, in der Spec als fn:range-from() / fn:range-to() -->
        <p>fn:range(("a", "b", "c", "d", "e"), matches(?, "c")):
          {fn:range(("a", "b", "c", "d", "e"), matches(?, "c"))}</p>
          <!-- ("c", "d", "e") -->

        <p>fn:highest(1 to 25, (), ->{{. idiv 10}}): 
          {fn:highest(1 to 25, (), ->{. idiv 10})}</p> <!-- 20 bis 25 bezogen auf Ergebnis 2 -->

        <p>fn:lowest(1 to 25, (), ->{{. idiv 10}}): 
          {fn:lowest(1 to 25, (), ->{. idiv 10})}</p> <!-- 1 bis 9 bezogen auf Ergebnis 0 -->      

        <p>fn:index-where(("blau", "gelb", "rot", "schwarz"), ->{{contains(., "a")}}): 
          {fn:index-where(("blau", "gelb", "rot", "schwarz"), ->{contains(., "a")})}</p> <!-- 1 4 -->

        <p>fn:index-where(1 to 10, ->{{. mod 2 = 0}})): 
          {fn:index-where(1 to 10, ->{. mod 2 = 0})}</p> <!-- 2 4 6 8 10 -->

        <!-- Sequences -->
        <xsl:variable name="s" select="('a', 'ab', 'abc', 'xyz')" as="item()*"/>

        <p>fn:items-after($s, function($x){{fn:string-length($x) = 1}}):
          {fn:items-after($s, function($x){fn:string-length($x) = 1})}</p> <!-- ("ab", "abc", "xyz") -->

        <p>fn:items-before($s, function($x){{fn:string-length($x) = 2}}):
          {fn:items-before($s, function($x){fn:string-length($x) = 2})}</p> <!-- ("a") -->

        <p>fn:items-from($s, function($x){{fn:string-length($x) = 3}}):
          {fn:items-from($s, function($x){fn:string-length($x) = 3})}</p> <!-- ("abc", "xyz") -->

        <p>fn:items-until($s, function($x){{fn:string-length($x) = 3}}):
          {fn:items-until($s, function($x){fn:string-length($x) = 3})}</p> <!-- ("a", "ab", "abc") -->

        <p>fn:slice(("a", "b", "c", "d", "e"), start:2, end:4): {fn:slice(("a", "b", "c", "d", "e"), start:2, end:4)}</p>
          <!-- ("b", "c", "d") -->
      </body>
    </html>

  </xsl:template>

</xsl:stylesheet>