469,647 Members | 1,789 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

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

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
1 1166
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.

Similar topics

2 posts views Thread by Jon Martin Solaas | last post: by
7 posts views Thread by Harolds | last post: by
3 posts views Thread by thomas.porschberg | last post: by
3 posts views Thread by super.raddish | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.