使用 XSLT 2 (saxon8) 将元素从一个地方移动到另一个地方
大家好,请帮助我使用 XSLT 2.0 生成以下输出。
我有这个:
<UL>
 <ITEM>
    aaa 
    <NL>iii
        <ITEM1>111</ITEM1>
        <ITEM2>222</ITEM2>
    </NL>
 </ITEM>
 <ITEM>
    bbb
    <NL>vvv
        <ITEM1>333</ITEM1>
        <ITEM2>444</ITEM2>
    </NL>
 </ITEM> 
</UL>
我需要制作这个
<UL>
 <ITEM>
    aaa
    <ITEM1>111</ITEM1>
 </ITEM>
 <ITEM>
    bbb
    <ITEM1>333</ITEM1>
 </ITEM>
 <NEW>
  <NL>iii
   <ITEM2>222</ITEM2>
  </NL> 
  <NL>vvv
   <ITEM2>444</ITEM2>
  </NL>
 </NEW>
</UL>
我正在尝试使用模式选项获取输出,如下所述:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()" />
        </xsl:copy>
    </xsl:template>
    <xsl:template match="NL"/>
    <xsl:template match="ITEM2"/>
    <xsl:template match="UL">
      <xsl:copy>
    <xsl:apply-templates/>
    <NEW>
      <xsl:apply-templates select="descendant::NL" mode="move"/>
    </NEW>
      </xsl:copy>
    </xsl:template>
    <xsl:template match="ITEM" mode="move">
        <xsl:copy>
            <xsl:apply-templates/>
        <xsl:apply-templates select="descendant::ITEM2" mode="move1"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="NL" mode="move">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="ITEM2" mode="move1">
        <xsl:copy>
            <xsl:apply-templates/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet> 
谢谢并恭祝安康
巴拉