Guest GarlicRice Posted November 5, 2008 Share Posted November 5, 2008 I'm need a min function in my XSLT but I keep getting the receiving the message "'min()' is an unknown XSLT function."Is min() only available in XSLT 2.0? If so, how do I specify that the sheet should use version 2?I'm not sure if it makes a difference, but I'm using .NET 2.0 XslCompiledTransform to perform the transform operation.Many thanks,Michael. Link to comment Share on other sites More sharing options...
boen_robot Posted November 9, 2008 Share Posted November 9, 2008 The XSLT processor you're using doesn't support XSLT 2.0.You can specify the version in the xsl:stylesheet element, like: <xsl:stylesheet version="2.0" ...> but like I said, your processor doesn't support it. It will still give that error (try it if you want).There are two things you can try:1. Use the math:min() EXSLT function. To use it, you'll have to download and include some of the contents in the ZIP file. You'll probably be forced to use the template notation rathar than the function. Only the implementations listed on that page support the function notation. See the How To page for more info on that one.2. Download and use an XSLT 2.0 processor. For .NET, you can use either of the two most popular XSLT 2.0 processor, AltovaXML or SAXON. Link to comment Share on other sites More sharing options...
aalbetski Posted November 10, 2008 Share Posted November 10, 2008 .NET does not support XSLT 2.0. You may want to do a sort by ascending order and then just take the first value, this will effectively do the min (or max) function <xsl:template match="/"> <xsl:for-each select="//data/value"> <xsl:sort select="." order="ascending" data-type="number" /> <xsl:if test="position()=1"> <xsl:value-of select="current()"/> </xsl:if> </xsl:for-each> </xsl:template> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.