Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   XSLT: Passing the whole source XML through to the result XML with only some elements altered (http://www.velocityreviews.com/forums/t362882-xslt-passing-the-whole-source-xml-through-to-the-result-xml-with-only-some-elements-altered.html)

tslettebo@hotmail.com 08-07-2006 07:43 PM

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ų


tslettebo@hotmail.com 08-07-2006 09:30 PM

Re: XSLT: Passing the whole source XML through to the result XML with only some elements altered
 
I found the answer myself, now, in this great FAQ:

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

It works great.



All times are GMT. The time now is 03:58 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.