<?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:function name="tm:addition" as="xs:decimal">
    <xsl:param name="a" as="xs:decimal"/>
    <xsl:param name="b" as="xs:decimal"/>
    <xsl:param name="c" as="xs:decimal"/>
    <xsl:param name="d" as="xs:decimal"/>
    <xsl:sequence select="$a + $b + $c + $d"/>
  </xsl:function>

  <!-- alternative Funktion mit selbem Namen ok -->
  <xsl:function name="tm:addition" as="xs:decimal">
    <xsl:param name="a" as="xs:decimal"/>
    <xsl:param name="b" as="xs:decimal"/>
    <xsl:sequence select="$a + $b"/>
  </xsl:function>
  
  <!-- neu als Einzelfunktion mit den Attributen required und select noch nicht in Saxon 11.4 -->
  <!-- Cannot find a 2-argument function named Q{http://www.datenverdrahten.de/tm}addition().
       The select attribute is not permitted on a function parameter -->
  <!--<xsl:function name="tm:addition" as="xs:decimal">
    <xsl:param name="a" as="xs:decimal"/>
    <xsl:param name="b" as="xs:decimal"/>
    <xsl:param name="c" as="xs:decimal" required="no" select="0"/>
    <xsl:param name="d" as="xs:decimal" required="no" select="0"/>
    <xsl:sequence select="$a + $b + $c + $d"/>
  </xsl:function>-->

  <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>xsl:function</title>
        <style>* {{ font-family: sans-serif; }}</style>
      </head>
      <body>
        <h1>xsl:function</h1>

        <p>{tm:addition(23,42)}</p>
        <p>{tm:addition(1,2,3,4)}</p>
      </body>
    </html>

  </xsl:template>

</xsl:stylesheet>