XPath xpath = myElem.createXPath( "/foo/bar:baz" );
xpath.setNamespaceContext( myContext );
/* or */
xpath.setNamespaceURIs( myMapOfMappings );
See the API docs for org.dom4j.Node and org.dom4j.XPath.
-bob
On Tue, 20 Aug 2002, Wannheden, Knut wrote:
> 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
>
--
Bob McWhirter [EMAIL PROTECTED]
The Werken Company http://werken.com/
-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user