Hi, I am serching an XPath function that works like the XPath 2.0 fn:max function. A function that returns the maximum of several parameters.
After searching a lot I figured out this way:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:math="http://exslt.org/math"
xmlns:exslt="http://exslt.org/common"
xmlns:func="http://exslt.org/functions"
xmlns:my="http://myns.com"
extension-element-prefixes="math exslt func">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<root>
<xsl:value-of select="my:max(1,2)"/>
</root>
</xsl:template>
<func:function name="my:max">
<xsl:param name="e1"/>
<xsl:param name="e2"/>
<xsl:variable name="x">
<val><xsl:value-of select="$e1"/></val>
<val><xsl:value-of select="$e2"/></val>
</xsl:variable>
<func:result select="math:max(exslt:node-set($x)/val)"/>
</func:function>
</xsl:stylesheet>
Is it possible to do it so that my max function can take more elements?
Cheers
Jan