Previous | Next | Indexes
Zvon > Tutorials > XSLT 2.0 Tutorial > Stylesheet Functions (10/11) >

Types of parameters

Expected types of function arguments can be explicitly given.

XSLT

      <xsl:stylesheet
                  xmlns:my="myFunctions"
                  xmlns:sch="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="2.0"
                  exclude-result-prefixes="my sch">
            <xsl:output  method="xml"
                        indent="yes"
                        omit-xml-declaration="yes"/>

            <xsl:function  name="my:return-number">
                  <xsl:param  name="a"
                              as="sch:string"/>
                  <xsl:param  name="b"
                              as="sch:double"/>
                  <xsl:value-of  select="$a"/>
                  <xsl:text>: </xsl:text>
                  <xsl:value-of  select="$b"/>
            </xsl:function>

            <xsl:template  match="/aaa">
                  <xxx>
                        <xsl:copy-of  select="my:return-number('Number',23)"/>
                  </xxx>
            </xsl:template>

      </xsl:stylesheet>
XML

      <aaa/>
Output

      <xxx>Number: 23</xxx>


Previous chapter: Variables and Parameters
Next chapter: Comparisons
Previous page: Return type errors
Next page: Mismatch in types of parameters and arguments