|
Subject: Re: [xsl] Inserting parts of a xml document From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Wed, 11 Apr 2001 15:23:45 +0100 |
Hi Martin,
> I simply want to insert test2.xml/root/a/* into test1.xml/root/a. So I wrote the
> following xslt:
>
> <xsl:template match="root/a">
> <xsl:apply-templates />
> <xsl:copy>
> <xsl:apply-templates select="document('test2.xml')/root/a/node()" />
> </xsl:copy>
> </xsl:template>
>
> But with this xslt the "<a>" and "</a>" are just around the second "<b>":
In the above template, you're creating the 'a' element with the
xsl:copy. The xsl:apply-templates before the copy is applying
templates to (and therefore copying, since you're using the identity
template) the children of a in test1.xml. The xsl:apply-template
within the copy is applying templates to (and therefore copying) the
children of a in test2.xml.
All you need to do is to make the result of applying the templates to
the children of a in test1.xml be added *within* the copy of the 'a'
element, rather than before it:
<xsl:template match="a">
<xsl:copy>
<xsl:apply-templates />
<xsl:apply-templates
select="document('test2.xml')/root/a/node()" />
</xsl:copy>
</xsl:template>
BTW, if this is all you're doing, you may as well use xsl:copy-of
rather than xsl:apply-templates, to save the processor working through
the nodes one by one:
<xsl:template match="a">
<xsl:copy>
<xsl:copy-of select="node()" />
<xsl:copy-of select="document('test2.xml')/root/a/node()" />
</xsl:copy>
</xsl:template>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Inserting parts of a xml docu, Martin Renner | Thread | Re: [xsl] Inserting parts of a xml , Oliver Becker |
| Re: [xsl] Inserting parts of a xml , Oliver Becker | Date | RE: [xsl] XSLT Conference Pictures, Clapham, Paul |
| Month |