有关xsl:param与xsl:variable的使用。
varpar.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v2006 (http://www.altova.com) -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:variable name="var1" select=" 'I am variable 1.'" />
<xsl:call-template name="to-be-called">
<xsl:with-param name="param1" select="$var1"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="to-be-called">
<xsl:param name="param1"/>
<html>
<body>
<param1><xsl:value-of select="$param1"/></param1>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
testvarpar.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="varpar.xsl"?>
<a></a>
不错,的确是变量与参数!
<xsl:variable name="newLineItems">
<xsl:for-each select="//lineItem"">
<lineItem>
<xsl:copy-of select="*"/>
<subTotal><xsl:value-of select="number(amount)*number(cost)"/></subTotal>
</lineItem>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="lineItemsTotal">
<xsl:value-of select="sum($newLineItems/subTotal)"/>
</xsl:variable>
浙公网安备 33010602011771号