您可以帮助我更好地理解代码的这一部分:
当调用'template1'时,发送了哪些参数以及使用哪些值?我知道的是,参数" xvalue"已发送到模板,但我不了解<xsl:param name="xValue" select="0"/>
。是否调用模板后的两个条件来确定要发送的参数的值?
<xsl:call-template name="template1">
<xsl:with-param name="xValue">
<xsl:choose>
<xsl:when test="string-length($var1)=1 ">
...
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</xsl:with-param>
</xsl:call-template>
<xsl:template name="template1">
<xsl:param name="xValue" select="0"/>
<xsl:param name="yValue" select="0"/>
<xsl:variable name="newValue">
<xsl:variable name="char" select="substring($xValue,1,1)"/>
<xsl:choose>
<xsl:when test="matches(upper-case($char),'[A-F]')">
...
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:choose>
<xsl:when test="not(string-length($xValue) = 1)">
...
</xsl:when>
<xsl:otherwise>
...
</xsl:otherwise>
</xsl:choose>
</xsl:template>
我不了解
<xsl:param name="xValue" select="0"/>
。
这将" 0"定义为xvalue参数的默认值。如果您以明确指定的不同值调用模板(如示例中所做的那样),则默认值被覆盖。
是调用模板后的两个条件以确定 发送参数的值?
是。更确切地说,有一个一个选择要确定要发送的值的语句;根据测试的结果,它有一个测试和两个值可供选择。
<xsl:param name="xValue" select="0"/>
正在定义一个名为 xValue
的参数,默认值为 0
。
当您在xsl:call-template
中使用<xsl:with-param name="xValue">
时,您正在覆盖该默认值。