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
Post a Comment