本文介绍了递归循环 XSLT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
全部,
我有以下 XSLT
<xsl:template name="loop">
<xsl:param name="count" select="1"/>
<xsl:if test="$count > 0">
<xsl:text> </xsl:text>
<xsl:value-of select="$count"/>
<xsl:call-template name="loop">
<xsl:with-param name="count" select="$count - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
调用方式是:
<xsl:call-template name="loop
<xsl:with-param name="count" select="100"/>
</xsl:call-template>
目前它显示从 100 到 0 的数字以及它们之间的空格.(100 99 98 97.....)
At the moment it displays numbers from 100 to 0 and space between them.(100 99 98 97.....)
我怎样才能改变它来做相反的事情?(1 2 3 4....)
How can I change it to do the opposite ? (1 2 3 4....)
非常感谢,
M
推荐答案
只需更改模板内的顺序:
Simply change the order inside the template:
<xsl:template name="loop">
<xsl:param name="count" select="1"/>
<xsl:if test="$count > 0">
<xsl:call-template name="loop">
<xsl:with-param name="count" select="$count - 1"/>
</xsl:call-template>
<xsl:value-of select="$count"/>
<xsl:text> </xsl:text>
</xsl:if>
</xsl:template>
这篇关于递归循环 XSLT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!