Re: [xsl] Moving elements of place

Subject: Re: [xsl] Moving elements of place
From: Mike Brown <mike@xxxxxxxx>
Date: Wed, 12 Mar 2003 23:07:34 -0700 (MST)
beatrizlangiano wrote:
> Hi, I need to make a stylesheet to transform XMI files.
> I need to remove some elements that are children of the  
> <XMI.content>, and put them after this element is 
> closed. (after </XMI.content>)

This is the third time today that we've suggested this:

Use the identity transform, as discussed in the XSLT spec under Copying:

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

This will result in a recursive copy of all nodes.

Add to it a template that matches the nodes you want to treat specially:

  <xsl:template match="XMI.content">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()[not(self::foo)]"/>
    </xsl:copy>
    <xsl:apply-templates select="foo"/>
  </xsl:template>

In this case, you're excluding the 'foo' element chilren of the 'XMI.content'
element from being processed until after the copy of the XMI.content element
is made.

Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread