I have xml file with sample data:
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet version="2.0" type="text/xml" href="xml_stylesheet.xsl" ?>
<root>
<values>
<item value="2" />
<item value="7" />
<item value="10" />
<item value="55" />
<item value="1" />
<item value="73" />
<item value="45" />
<item value="41" />
</values>
</root>
and xsl template:
<xsl:stylesheet version="2.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" >
<xsl:strip-space elements="*"/>
<xsl:template match="/" >
<html>
<body>
<div>
The minimum of values is <strong><xsl:value-of select="fn:min(//item/@value)" /></strong>
</div>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
How can i use min function? when i try to open .xml file in firefox (and other browsers) , it display error message. Why? what is wrong?
Firefox, and other browsers in general, do not support XSLT 2.0. You’ll have to use XSLT 1.0 and find an alternative for min(), which is from XPath 2.0.
See also: XPath and min function not recognized in xslt