热门:网页模板.net视频教程JQueryMVCjsonExtJs源码示例三级联动JQuery菜单
您现在的位置:.Net中文社区>> XML编程>>正文内容

在XSL中引用自身数据的两种方法

发布时间:2008年12月03日点击数: 孟宪会

在XSL中引用自身数据的两种方法,如果你使用Msxml解析器,你可以用方法二:

 

方法一

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mxh="http://www.aspxcs.net/">
  <xsl:template match="/">
    <mxh:Root>
      <Line Val="1"/>
      <Line Val="2"/>
      <Line Val="3"/>
    </mxh:Root>
    <xsl:for-each select="document('')/xsl:stylesheet/xsl:template/mxh:Root/Line">
      <xsl:value-of select="@Val"/>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

方法二

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"  
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
    xmlns:msxsl="urn:schemas-microsoft-com:xslt">
  <xsl:template match="/">
    <xsl:variable name="Array">
      <Root>
        <Line Val="1"/>
        <Line Val="2"/>
        <Line Val="3"/>
      </Root>
    </xsl:variable>
    <xsl:for-each select="msxsl:node-set($Array)/Root/Line">
      <xsl:value-of select="@Val"/>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

本站热点业务

更多模板/案例展示

热门推荐

关于我们 | 联系我们 | 团队日志 | 网站地图 | 网站合作