以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XQuery/XLink/XPointer/ 』  (http://bbs.xml.org.cn/list.asp?boardid=14)
----  请教xsl中实现循环的功能(与xml无关)  (http://bbs.xml.org.cn/dispbbs.asp?boardid=14&rootid=&id=18530)


--  作者:bestjamie
--  发布时间:5/19/2005 4:05:00 PM

--  请教xsl中实现循环的功能(与xml无关)
大家好。
我请教一个问题:
例如我想在页面上生成30个checkbox,但这与xml无关。
我的意思是只是单纯的想生成30个checkbox
请问是否能用类似循环的方法实现这个效果?
谢谢。
--  作者:hjhit2000
--  发布时间:5/26/2005 11:24:00 AM

--  用递归
XSL 不推荐使用循环,而是用递归来实现.
--  作者:kahon
--  发布时间:5/30/2005 8:09:00 PM

--  
请用其他脚本语言写,xsl 不支持赋值之类的操作。
--  作者:kahon
--  发布时间:5/30/2005 11:30:00 PM

--  
变通的方法如下:
<xsl:template name="print-checkbox">

  <xsl:param name="count"/>

  <!-- The termination condition -->

  <xsl:if test="$count">

    <!-- print the checkbox for this iteration -->

    <xsl:text>对checkbox的处理,看你怎么做</xsl:text>

    <!-- recursive call to print remaining checkboxs -->

    <xsl:call-template name="print-checkbox">

      <xsl:param name="count" select="$count-1"/>

    </xsl:call-template>

  </xsl:if>

</xsl:template>


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
31.250ms