Attemping to build a template in XSLT to match on a specific Xpath case.
In this example XML document I want to match on all the text in the entire document except for in <x>
:
<root>
<tag1> I want this text </tag1>
<tag2> I want this text </tag2>
<x> I don't want to match on this text </x>
<tag3> I want this text </tag3>
</root>
Any ideas on this Xpath? I'm trying to build a template for it to transform my document for this specific case.
What I have come up with some far is something like this that's not working:
<xsl:template match="text()[not(matches(.,x))]">
Any ideas?
When you write . it takes the string value of the text node, not the node-name of the parent. And matches needs a string prarameter
You could write it as:
<xsl:template match="text()[not(matches(name(..),'x'))]">
Or better:
<xsl:template match="text()[not(parent::x)]">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With