以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XSL/XSLT/XSL-FO/CSS 』  (http://bbs.xml.org.cn/list.asp?boardid=8)
----  xslt处理xml时。为何多出内容。求解  (http://bbs.xml.org.cn/dispbbs.asp?boardid=8&rootid=&id=127166)


--  作者:fencc
--  发布时间:11/8/2013 9:53:00 AM

--  xslt处理xml时。为何多出内容。求解

<?xml version="1.0"?>
<xsl:stylesheet version="2.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

 <xsl:template match="@*|node()">
  <xsl:copy>
   <xsl:apply-templates/>
  </xsl:copy>
 </xsl:template>
 <xsl:template match="Sense">
  <xsl:for-each select="parent::node()">
   <xsl:choose>
    <xsl:when test="count(Sense)&gt;1">
     <xsl:for-each select="Sense">
      <Sense>
       <sz>
        <xsl:number format="1"/>
       </sz>
       <xsl:apply-templates/>
      </Sense>
     </xsl:for-each>
    </xsl:when>
   </xsl:choose>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>



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