引用xslt中的变量?

时间:2016-12-13 06:53:59

标签: xml xslt xslt-1.0 xslt-2.0

我有以下变量硬编码

<xsl:variable name="innerSubElement">
      <entry key="all">all</entry>
      <entry key="nD">nD</entry>
      <entry key="cC">cC</entry>
    </xsl:variable>


    <xsl:variable name="nD">
       <nT colNumber="104"></nT>
      <dvI colNumber="105"></dvI>
      <mP colNumber="106"></mP>
      <qC colNumber="107"></qC>
    </xsl:variable>

  <xsl:if test="$innerSubElement/entry[@key = $innerElement]">
          <xsl:call-template name="subElementProcess">
          </xsl:call-template>
      </xsl:if>

<xsl:template name="subElementProcess">

     <xsl:variable name="array">
          <xsl:for-each select="./*">
            <v ><xsl:value-of select="local-name()"/></v>
          </xsl:for-each>
        </xsl:variable>
         <!-- <xsl:for-each select="exsl:node-set($array)/v">
            <p><xsl:value-of select="."/></p>
        </xsl:for-each> -->

      <xsl:variable name="data">
        <xsl:if test="$nD/*[not(./name() = $array/v)]">

     <xsl:copy-of select="$nD/*[not(./name() = $array/v)]"/>
            <xsl:variable name="quantityContained">
                <xsl:copy-of select="$nD/*[not(./name() = $array/v)]"/>
            </xsl:variable>
            <xsl:for-each select="exsl:node-set($quantityContained)/*">

                <xsl:if test="local-name() = 'quantityContained'">

                    <measurementUnitCode colNumber="108"></measurementUnitCode>
                </xsl:if>
            </xsl:for-each>

          </xsl:if>
    </xsl:variable>

    <xsl:choose>
    <xsl:when test="quantityContained">
     <xsl:for-each select="quantityContained">
        <xsl:for-each select="exsl:node-set($data)">
            <xsl:copy-of select="*"/>
        </xsl:for-each>  
    </xsl:for-each>
  </xsl:when>
  <xsl:otherwise>
      <xsl:for-each select="exsl:node-set($data)">
            <xsl:copy-of select="*"/>
        </xsl:for-each>  
  </xsl:otherwise>
</xsl:choose>
</xsl:template>

现在,当我收到nD作为来自innerSubElement变量数组的匹配项时,我正在遍历我的xml文件。我如何在调用nD变量数组时引用它,我直接在调用模板中放置了nD,而我想从变量中调用它?

0 个答案:

没有答案