tags:

views:

24

answers:

1

I have the following piece of code:

root="//valueExpression[matches(self::*,'pattern')]/.."

But I can only use XPath 1.0 and I get an exception for the function matches(). Can you please help me with a solution using only functions from XPath 1.0 ?

A: 

Generally, this can't be done just using XPath 1.0.

However, there is a set of standard XPath 1.0 functions that you can use for string processing:

  • substring()
  • substring-before()
  • substring-after()
  • translate()
  • normalize-space()
  • string-length()
  • count()
Dimitre Novatchev
I know these functions... but somehow I need a solution... if anyone can help.
Jenny Smith
@Jenny-Smith: There's no way to have the function `matches()` in XSLT 1.0 unless you implement it yourself as an extension function. If you can do with something "similar" but not exactly the same, consider using the RegEx module of EXSLT -- if your XSLT processor implements EXSLT, it may implement the RegEx module. If you need XPath nor hosted in XSLT, then only the first option remains.
Dimitre Novatchev