Subject: Re: [xsl] flattening an xml hierarchy From: "Vasu Chakkera" <vasucv@xxxxxxxxx> Date: Fri, 9 Jan 2009 10:30:35 +0000 |
>>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. True.. 2009/1/9 Vasu Chakkera <vasucv@xxxxxxxxx>: > On 08/01/2009, Evan Lenz <evan@xxxxxxxxxxxx> wrote: >> 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. >> >> Evan >> >> Vasu Chakkera wrote: >>> USe identity transformation. >>> >>> <xsl:stylesheet 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 = "Dontwant1"> >>> <xsl:apply-templates select="node()|@*"/> >>> </xsl:template> >>> <xsl:template match = "dontwant2"/> >>> </xsl:stylesheet> >>> >>> 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. >>> >>> HTH >>> >>> 2009/1/8 Tim <timlhunt@xxxxxxxxxxxxxx>: >>> >>>> 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 >> >> > > > -- > Vasu Chakkera > Numerical Algorithms Group Ltd. > Oxford > www.vasucv.com > -- Vasu Chakkera Numerical Algorithms Group Ltd. Oxford www.vasucv.com
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] flattening an xml hierarc, Vasu Chakkera | Thread | [xsl] How to call an external Java , Ylvisaker, Steve |
Re: [xsl] flattening an xml hierarc, Vasu Chakkera | Date | Re: [xsl] Categorise Node by Unique, William Warby |
Month |