Xml 如何使用xsl 2.0函数
我有一个包含示例数据的xml文件:Xml 如何使用xsl 2.0函数,xml,xslt,xpath,xslt-2.0,Xml,Xslt,Xpath,Xslt 2.0,我有一个包含示例数据的xml文件: <?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" />
<?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>
和xsl模板:
<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>
最小值为
如何使用min函数?当我尝试在firefox(和其他浏览器)中打开.xml文件时,它会显示错误消息。为什么?怎么了?Firefox和其他浏览器一般不支持XSLT 2.0。您必须使用XSLT1.0并为min()找到一个替代方法,它来自XPath2.0
另请参见:Firefox和其他浏览器一般不支持XSLT2.0。您必须使用XSLT1.0并为min()找到一个替代方法,它来自XPath2.0
另请参见:浏览器中的本机XSLT处理器都是XSLT 1.0。如果您想在浏览器中使用XSLT 2.0,可以查看Saxon CE。浏览器中的本机XSLT处理器都是XSLT 1.0。如果您想在浏览器中使用XSLT 2.0,可以查看Saxon CE。使用XSLT 2.0的JavaScript实现之一: