以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  变量重定义问题!  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=12431)


--  作者:soonwind
--  发布时间:12/1/2004 11:55:00 AM

--  变量重定义问题!
<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml"/>

<xsl:template match="/*">
 <DATA>
  <HEAD>
   <xsl:for-each select = "HEAD">
    <xsl:copy-of select="*"/>
   </xsl:for-each>
  </HEAD>
  <BODY>
   <xsl:variable name="startRow" select="BODY/ROW[@XH=1]/@INDEX - 1"/>
   <xsl:variable name="intXh" select="1"/>
   <xsl:for-each select="BODY/ROW">
    <xsl:if test="DWDM='3307230002'">
     <xsl:element name="ROW">
      <xsl:attribute name="INDEX"><xsl:value-of select="$startRow+$intXh"/></xsl:attribute>
      <xsl:attribute name="XH"><xsl:value-of select="$intXh"/></xsl:attribute>
      <xsl:copy-of select="*"/>
      <xsl:variable name="intXh" select="$intXh+1"/>
     </xsl:element>
    </xsl:if>
   </xsl:for-each>
  </BODY>
 </DATA>
</xsl:template>
</xsl:stylesheet>

上面报错intXh重定义,我的意思要intXh+1,请问大虾怎么做呀?


--  作者:doubleG
--  发布时间:12/1/2004 1:17:00 PM

--  
在xslt中,一个variable一旦被声明就不能改动了,如果要实现<xsl:variable name="intXh" select="$intXh+1"/>
这样的功能只能在递归函数中实现,也就是变了味道的i=i+1
--  作者:soonwind
--  发布时间:12/1/2004 4:06:00 PM

--  
谢谢!用了递归太复杂,还是用脚本来处理吧!


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