[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Move XML elements to one place using XSLT 2.0

Subject: Re: Move XML elements to one place using XSLT 2.0
From: "Christian Roth" <roth@xxxxxxxxxxxxxx>
Date: Thu, 18 Mar 2010 11:30:14 +0100
Re:  Move XML elements to one place using XSLT 2.0
>Here comes the difficult part: How can I change the following style
>sheet to do the re-shuffling without touching the first three
><xsl:template match="a">
><xsl:template match="b">
><xsl:template match="c">
><xsl:template match="note">

My idea would be to use modes. First, in the normal processing mode, you
want to disregard <note>, so you change the existing note template to

<xsl:template match="note" />

Then, you add a new template for note that actually does what you need
to do with note, but in a specific mode:

<xsl:template match="note" mode="noteprocessing">

Finally, you add a note-collecting apply-templates call to the template
for <root>:

<xsl:template match="root">
  <xsl:apply-templates /> <!-- just what you already have -->

  <!-- new: -->
  <xsl:apply-templates select="descendant::note" mode="noteprocessing" />

Mind that in any calls to apply-templates in the mode'd note template,
you should add mode="#default" to resume using the non-moded templates
for the note element contents.


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.