2016-03-28 59 views
0

我想複製和更改另一個xml數據中的數據。除了正常的兩個輸入xml文件之外,我還有一個額外的xml文件。我想將這個xml文件的全部內容嵌入到我的輸出xml中,然後改變它的某些方面。我已成功通過全部文件複製到右側區域這樣做,因爲這樣所需的(感謝這個帖子here):使用xslt更改複製的xml文件中的節點

<test> 
<xsl:copy-of select="document('filename.xml')/*"/> 
</test> 

問題是,我想改變一些數據的文件名,我不我知道我該如何做到這一點。也許是沿着這條線?

<xsl:template match="document('filename.xml')/root/elemntToBeChanged"> 
    <xsl:apply-templates select="Test/changeItToThis"/> 

回答

0

試試這個, XSLT 2.0:

<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="root"><!--Input document's root element --> 
    <xsl:copy><xsl:apply-templates select="*|document('External-Doc.xml')"/></xsl:copy><!--Extrenal document called here --> 
</xsl:template> 

</xsl:stylesheet>