How to remove part of attached xml with xslt?
Lets assume we have xml:
<tag1> text <tag2> { <tag3> name1 </tag3>:<tag4><val>value1</val>;</tag4> <tag3> name2 <开发者_C百科/tag3>:<tag4><val>value2</val>;</tag4> }</tag2> </tag1>
How to remove whole line with name1 and value1 (from <tag3> to </tag4>) with xslt?
I have no problem to remove tag3 and tag4 but this colon (':') character is problematic for me.
Here is a solution which is very ugly but it works. It's ugly because the condition has to be repeated 3 times. There must be a simpler way to do that.
<xsl:template match="tag3[text()=' name1 ' and following-sibling::tag4[val/text()='value1']]"/>
<xsl:template match="text()[preceding-sibling::tag3[text()=' name1 '] and following-sibling::tag4/val[text()='value1']]" />
<xsl:template match="tag4[val/text()='value1' and preceding-sibling::tag3[text()=' name1 ']]" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
精彩评论