xsl-list
[Top] [All Lists]

[xsl] Moving elements during identity transformation

2010-09-01 10:50:07
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>