将一个节点的内容复制到另一个节点

时间:2017-07-18 21:19:19

标签: xslt-1.0

使用XLST 1.0我想将名为INSTRUCTIONS的任何节点和子元素复制到树中的另一个位置。

WO下可以有多个INSTRUCTIONS容器。

/my:TRANS/my:DE/my:CO/my:RE/my:PR/my:WO

INSTRUCTIONS的目标位置在PRSI下,原始来源中不存在PRSI。

/my:TRANS/my:DE/my:CO/my:RE/my:PR/my:PRSI

请告知。

这是一些示例输入。我省略了命名空间:

<trans>
<de>
<co>
<re>
<pr>
<wo>
<INSTRUCTIONS>
<category>1</category>
<description>abc</description>
</INSTRUCTIONS>
<INSTRUCTIONS>
<category>2</category>
<description>xyz</description>
</INSTRUCTIONS>
</wo>
</pr>
</re>
</co>
</de>
</trans>

这是预期的输出。我省略了命名空间:

<trans>
<de>
<co>
<re>
<pr>
<PRSI>
<INSTRUCTIONS>
<category>1</category>
<description>abc</description>
</INSTRUCTIONS>
<INSTRUCTIONS>
<category>2</category>
<description>xyz</description>
</INSTRUCTIONS>
</PRSI>
</pr>
</re>
</co>
</de>
</trans>

这是我到目前为止所做的。

  <xsl:template match="//my:TRANS/my:DE/my:CO/my:RE/my:PR/my:WO">
    <my:PRSI>
    <xsl:copy>
      <xsl:copy-of select="@* | node()" />
      <xsl:apply-templates select="*" />
     </xsl:copy>
    </my:PRSI>
  </xsl:template>

0 个答案:

没有答案
相关问题