Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT: Passing the whole source XML through to the result XML with only some elements altered

Reply
Thread Tools

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

 
 
tslettebo@hotmail.com
Guest
Posts: n/a
 
      08-07-2006
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°

 
Reply With Quote
 
 
 
 
tslettebo@hotmail.com
Guest
Posts: n/a
 
      08-07-2006
I found the answer myself, now, in this great FAQ:

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

It works great.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*WITHOUT* using: ValidateRequest="False" for the whole page (or my whole site).... \A_Michigan_User\ ASP .Net 2 08-21-2006 02:13 PM
To allow left click only on some elements of web page NOT all elements vikas.khengare@gmail.com Javascript 1 05-31-2006 09:26 AM
Can the Profile data be altered by the client? Christian D÷ring ASP .Net 2 04-20-2006 05:10 PM
1. Ruby result: 101 seconds , 2. Java result:9.8 seconds, 3. Perl result:62 seconds Michael Tan Ruby 32 07-21-2005 03:23 PM
Web page has altered my home page in IE 5.5 Harry the Horse Computer Support 3 07-11-2003 12:11 AM



Advertisments