根据某些条件和模板匹配,通过xsl将节点复制到另一个节点

时间:2014-01-17 20:28:30

标签: xslt

我有一个像下面这样的xml: -

   <featuresList>
        <existing>
          <featureService>
            <featureServiceCode>S001L</featureServiceCode>
            <additionalInfo>
              <key>V0948</key>
              <value>2013-07-07</value>
            </additionalInfo>
          </featureService>
        </existing>
        <configured>
          <featureService>
            <featureServiceCode>S001J</featureServiceCode>
            <additionalInfo>
              <key>V0949</key>
              <value>2013-07-05</value>
            </additionalInfo>
          </featureService>
        </configured>
      </featuresList>
      <serviceLevelLegalList>
        <existing>
          <serviceLevel>
            <serviceCode>S001J</serviceCode>
            <serviceName>Vorrangige Entstörung</serviceName>
            <additionalInfo>
              <key>V0947</key>
              <value>2013-07-04</value>
            </additionalInfo>
          </serviceLevel>
        </existing>
        <configured>
          <serviceLevel>
            <serviceCode>S001J</serviceCode>
            <serviceName>Vorrangige Entstörung</serviceName>
            <additionalInfo>
              <key>V0949</key>
              <value>2013-07-05</value>
            </additionalInfo>
          </serviceLevel>
        </configured>
      </serviceLevelLegalList>

我的要求是我需要将serviceLevelLegalList /(现有或已配置)/ serviceLevel中的元素复制到featuresList /(现有或已配置)/ featureService。

我正在尝试类似下面的内容,但它没有给我预期的输出。

<xsl:template match="functions/*[name()='internet' or name()='voice']/*[contains(name(),'Configuration')]">
  <xsl:element name="{name()}">
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>

  <xsl:if test="featuresList/configured/featureService/* and serviceLevelLegalList/configured/serviceLevel/* ">
          <xsl:copy-of select="serviceLevelLegalList/configured/serviceLevel/* "/>
  </xsl:if>
  </xsl:element>
</xsl:template>
你可以帮我解决这个问题。

0 个答案:

没有答案