I have XML like this:
<a>
<b>
<c>some text here</c>
</b>
</a>
<a>
<b>
<c>another cool text</c>
</b>
</a>
I need to match word “cool” inside //a/b/c/text() and transform the XML like this
<a>
<b>
<c>some text here</c>
</b>
</a>
<x>
<y> prepend to cool text </y>
</x>
<a>
<b>
<c>another cool text</c>
</b>
</a>
I tried this:
<xsl:template
match="//a/b/c/matches(text(),'\.*cool\*.')">
...
</xsl:template>
but with no luck:
XTSE0340: XSLT Pattern syntax error at char 153 on line 30 in {...\.*cool\*...}:
Function call may appear only at the start of a pattern
what am I missing here?
Your match is not correct, it should test inside brackets
[]:Besides, if your regexp is that easy, then you can use the XPath method
contains().