By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,271 Members | 1,289 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,271 IT Pros & Developers. It's quick & easy.

XSLT: Passing the whole source XML through to the result XML with only some elements altered

P: n/a
Hi all.

I've read Michael Kay's "XSLT" book, and used XSLT successfully as an
HTML template system at our company (using basically the
"fill-in-the-blanks" pattern of XSLT use: A template matching the root
node, containing the HTML page, with lots of <xsl:value-of.../>, etc.).

However, I've recently got a task that got me stumped, and I don't know
if I'm missing something obvious, but quite frankly, I don't know where
in the sea of XSLT-information to start looking (although I'll continue
with that after having posted this), that I kindly ask for some
guidance from you.

The problem is this: We have a quite complex source XML document like
this (each element may have several attributes):

<root>
<element1 ...>
<element2...>
<element3...>
<element4...>
...
</element4>
</element3>
.... (lots more elements and attributes)

We'd like to basically copy this to the result XML, as it is, but
change a few of the elements, like this:

<root>
<element1 ...>
<element2...>
<element3...>
<element4...>
<new_element...>
<another_new..../>
</new_element>
</element4>
</element3>
.... (lots more elements and attributes)

Is there a way to write an XSLT template that does this (passes the
source XML unchanged, and changing only some elements), without
creating a massive XSLT template that does a match on each element type
in the source XML, having to enumerate all atttributes that has to be
copied, etc.?

Any hints or pointers appreciated.

Regards,

Terje Slettebų

Aug 7 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I found the answer myself, now, in this great FAQ:

http://www.dpawson.co.uk/xsl/sect2/N1930.html#d2959e172

It works great.

Aug 7 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.