所以我从来没有使用过XSLT,而且我只用XPath作为最简单的形式。 我有一个Xml元素“Earth”,有两个属性Stamina和Willpower。两者都包含数字。 我想要做的是在“地球”一词旁边显示这些属性中最小的值。 我似乎无法锻炼如何在XPath中调用函数。XPath,获取min属性的值
这里是我的XSLT
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
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"
version="2.0">
<!--<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl">
-->
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="//Rings"/>
</body>
</html>
</xsl:template>
<xsl:template match="//Rings">
<h2>Rings</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Earth</th>
<th>
<xsl:value-of select="fn:min(fn:number(Earth/@*))"/>
</th>
</tr>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
我在W3eC上找到的XLST的所有示例都很简单。 –