Re: [xsl] flattening an xml hierarchy

Subject: Re: [xsl] flattening an xml hierarchy
From: Evan Lenz <evan@xxxxxxxxxxxx>
Date: Thu, 08 Jan 2009 15:19:30 -0800
You probably don't want to process attributes of the unwanted elements. With your code below, an attribute on <Dontwant1> would cause a run-time error.


Vasu Chakkera wrote:
USe identity transformation.

<xsl:stylesheet version="1.0" xmlns:xsl="";>
	<xsl:template match="node()|@*">
			<xsl:apply-templates select="node()|@*"/>
	<xsl:template match = "Dontwant1">
		<xsl:apply-templates select="node()|@*"/>
	<xsl:template match = "dontwant2"/>

This will do your job. Although.. You have 2 definitions of what you
want to Remove.

1. Node and its children
2. Node .

I am not sure what you meant by "remove" But anyway, in either case,
if you want to remove node and all its children, you just define an
empty template
if you want to ignore the node alone, then you define the template for
that node and not bothor about copying the current node, and copy all
its children.


2009/1/8 Tim <timlhunt@xxxxxxxxxxxxxx>:
I'd like to remove some elements from an xml hierachy using xslt:

Original xml example:
      <y5>more stuff</y5>

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

Thanks for your insghts.


Current Thread