Title: [Q] How do I create an XPath with a NamespaceContext?

Hi,

I would like to evaluate an XPath expression which uses a function from a custom library, which is associated with a namespace.  So the expression looks like this:

        re:match('abc', '?b?')

As I understand it I have to create an XPath object and associate a NamespaceContext and a FunctionContext with it using XPath.setNamespaceContext() and XPath.setFunctionContext() respectively.  But I already get an exception when I try to create the XPath object:

org.dom4j.InvalidXPathException: Invalid XPath expression: re:match('abc', '?b?') Unexpected '('
        at org.dom4j.xpath.DefaultXPath.parse(DefaultXPath.java:316)
        at org.dom4j.xpath.DefaultXPath.<init>(DefaultXPath.java:63)
        at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:182)

If I however remove the namespace from the expression (yielding "match('abc', '?b?')") it works!

I just can't figure out how to do this... Can someone tell me what I have to do?

Regards,

--
knut

Reply via email to