2014-07-14 34 views
-1

一個內容複製到另一個標籤內容我有一個標籤:如何使用XSLT

<footnote xml:id="ch03-fn-5" label="5"><para aid:pstyle="Copytext">„Muchacho「 (1924), Musik: Luis N. Visca, Text: Celedonio Esteban Flores.</para></footnote> 

我想創造新的標籤「ftnote」與上述「footnote」標籤相同的屬性和內容。它應該是這樣的:

<ftnote xml:id="ch03-fn-5" label="5"><para aid:pstyle="Copytext">„Muchacho「 (1924), Musik: Luis N. Visca, Text: Celedonio Esteban Flores.</para></ftnote> 

能有人給這個

任何解決方案,謝謝!

回答

2

第一個用於複製xml節點的模板..第二個用於更改元素名稱: 注意:您的XML輸入是buggy。缺少「aid」前綴的名稱空間聲明。

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 

<xsl:template match="node() | @*"> 
    <xsl:copy> 
     <xsl:apply-templates match="node() | @*"/> 
    </xsl:copy> 
</xsl:template> 
<xsl:template match="footnote"> 
    <ftnote> 
     <xsl:apply-templates select="@* | node()"/> 
    </ftnote> 
</xsl:template> 
</xsl:stylesheet>