xslt - Removing XML Node In Matching Context -


i want remove element bar from

<data><foo>1</foo><bar><bla /></bar></data> <data><foo>2</foo><bar><bla /></bar></data> <data><foo>3</foo><bar><bla /></bar></data> 

but if foo matches 2. result should looks like:

<data><foo>2</foo></data> 

i use following code:

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

is there better way?

this way, not sure if make difference because matching condition quite simple in first place :

<xsl:template match="data[foo = 2]/bar" /> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -