RE: [xsl] xslt: Wrapping multiple elements in a parent element

Subject: RE: [xsl] xslt: Wrapping multiple elements in a parent element
From: David Neary <David@xxxxxxxxx>
Date: Fri, 9 May 2003 09:40:58 +0200

De : Steven Curry [mailto:scurry1@xxxxxxx]
> I need to do an xml to xml transformation where I take 1 or 
> more elements of 
> a certain name (they are grouped together somewhere in the 
> hierarchy) and 
> wrap them in a new parent element.  The rest of the document 
> should stay the 
> same.  Any xslt suggestions?  I'm sure there is any easy 
> solution but I 
> haven't found it yet.

Hi Steve,

Use the identity transformation for all elements except the ones you're
interested. That is, 

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

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

Cheers,
Dave.

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


Current Thread