xsl-list
[Top] [All Lists]

RE: Moving an element to a new location in the Result-tree

2005-09-07 17:38:51
Jim Graves writes:
Yes, I'm probably am thinking in a procedural manner, more than
50%/time.
Please let me clarify my problem with more details:

Let's suppose my source document looks like this: (note: repeating "b1"
elements)

I want to move the former "b1" elements down the tree and re-name them
(all) along the way,

Here is the key.  You aren?t moving or renaming anything.

You are creating an entirely new document.  It may or may not bear any
resemblance to the input document.

Think in those terms, and you will achieve victory! (-:

Here?s a transformation.  It?s just the identity transform, but the
children of document1 aren?t processed in document order.

<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

<xsl:template match="@*|node()">
  <xsl:copy>
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>

<xsl:template match="document1">
  <document222>
    <xsl:apply-templates select="*[not(self::b1)]"/>
    <xsl:apply-templates select="b1"/>
  </document222>
</xsl:template>

</xsl:transform>

~Chris
-- 
Christopher R. Maden, Principal Consultant, crism consulting
XML-SGML-HTML-DTDs-schemas-XSL-DSSSL-conversion-training-ebooks-B2B
<URL: http://crism.maden.org/consulting/ >
PGP Fingerprint: BBA6 4085 DED0 E176 D6D4  5DFC AC52 F825 AFEC 58DA


--~------------------------------------------------------------------
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>
--~--