Re: [xsl] flattening an xml hierarchy

Subject: Re: [xsl] flattening an xml hierarchy
From: Evan Lenz <evan@xxxxxxxxxxxx>
Date: Thu, 08 Jan 2009 08:14:59 -0800
This is a very simple modified identity transform:

<!-- Copy everything unchanged... -->
<xsl:template match="@* | node()">
 <xsl:apply-templates select="@* | node()"/>
</xsl:template>

<!-- ...except for these elements -->
<xsl:template match="Dontwant1 | dontwant2">
 <xsl:apply-templates/>  <!-- Just process their contents -->
</xsl:template>

Evan

Tim wrote:
Hi,
I'd like to remove some elements from an xml hierachy using xslt:

Original xml example:
<Dontwant1>
   <dontwant2>foo</dontwant2>
   <x3>
       <x4>stuff</x4>
       <y5>more stuff</y5>
   </x3>
</Dontwant1>

Like to have transform output:
<x3>
  <x4>stuff</x4>
   <y5>more stuff</y5>
</x3>

Thanks for your insghts.

Tim

Current Thread