How to copy an external XML inside another using XSLT processor?

1

I have this first xml file1.xml :

<?xml version="1.0" encoding="utf-8"?>
<node1>
     <node2>
     </node2>
</node1>

And this second xml file2.xml :

<?xml version="1.0" encoding="utf-8"?>
<node2>
    <node3>
    </node3>
</node2>

I want to have this after XSLT processing :

<node1>
    <node2>
        <node3>
        </node3>
    </node2>
</node1>

For this I use this XSLT script (which is in the same directory as file2.xml) :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="node2">  
        <xsl:copy>
            <xsl:copy-of select="document('file2.xml')//node2" />
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

I use MSXL processor, when I executes the script I have this output :

Error occurred while executing stylesheet

Code: 0x800c0006

System error: -2146697210.

How I can obtain my result xml file ?

xml
xslt
xml-parsing
asked on Stack Overflow Feb 10, 2015 by backlash • edited Feb 10, 2015 by (unknown user)

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0