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

Re: Moving elements during identity transformation

Subject: Re: Moving elements during identity transformation
From: Martynas Jusevicius <martynas.jusevicius@xxxxxxxxx>
Date: Fri, 3 Sep 2010 12:14:40 +0200
Re:  Moving elements during identity transformation
That's'exactly how I solved it :)

On Thu, Sep 2, 2010 at 12:05 PM, Praveen Chauhan
<praveen.chauhan@xxxxxxxxxxxxxx> wrote:
> Hi Martynas,
>
> You can update your xslt with below code
>
>
>      <xsl:template match="Index">
>      <xsl:apply-templates select="//ToC" mode="disp"/>
>
>      <xsl:copy>
>         <xsl:apply-templates select="@* | node()"/>
>      </xsl:copy>
>   </xsl:template>
>
>   <xsl:template match="ToC"/>
>
>   <xsl:template match="ToC" mode="disp">
>         <xsl:apply-templates/>
>   </xsl:template>
>
> Please let me know if its not fulfills your requirements.
>
> Thanks
> Praveen Chauhan
> Aptara (India)
>
> -----Original Message-----
> From: Martynas Jusevicius [mailto:martynas.jusevicius@xxxxxxxxx]
> Sent: Wednesday, September 01, 2010 9:20 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Moving elements during identity transformation
>
> Hey list,
>
> I'm doing an identity transformation which cleans up, filters and moves
> around elements from my source document.
>
> Let's say there is <ToC> anywhere in the document, and from there it has to
> be moved directly *before* <Index> element, wherever that one is.
>
> What I'm doing is this:
>
>        <xsl:template match="Index">
>                <xsl:apply-templates select="/ToC"/> <!-- lets just say this
> selects ToC -->
>                <xsl:copy>
>                    <xsl:apply-templates select="@* | node()"/>
>                </xsl:copy>
>        </xsl:template>
>
> So the <ToC> is now at its new location, but the old one has still to be
> removed:
>
>        <xsl:template match="ToC"/>
>
> Now the problem is, this will also remove the new <ToC>. Since this is a
> identity transformation, I don't want to use <xsl:copy-of>, as some of the
> <ToC> descendants might also need processing.
>
> What do you do in such situation?
> The only thing I can think of is introducing some parameter like $keep in
> the <ToC> template and then pass it from the <Index> template to
> differentiate between the two cases.
>
> Thanks,
>
> Martynas
> semantic-web.dk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.