Title: RE: [dom4j-user] [Q] How do I create an XPath with a NamespaceCon text?

Well, that's what I'm trying to do, but I thought I have to register it with the XPath object.  And since the expression won't parse, I don't get an XPath object.  I guess I could register the function with the global FunctionContext (XPathFunctionContext.getInstance()), but I haven't tried that yet.  And further, I guess I have to register the namespace with some global NamespaceContext as well, and I don't know how to do that...

--
knut

> -----Original Message-----
> From: bob mcwhirter [mailto:[EMAIL PROTECTED]]
> Sent: Dienstag, 20. August 2002 17:27
> To: Wannheden, Knut
> Cc: '[EMAIL PROTECTED]'
> Subject: RE: [dom4j-user] [Q] How do I create an XPath with a
> NamespaceCon text?
>
>
>
> I think jaxen -may- have an issue with functions in a namespace.
>
> You've registered bar:baz() with a FunctionContext?
>
>       -bob
>
>
> On Tue, 20 Aug 2002, Wannheden, Knut wrote:
>
> > Doing it the way you suggest seems to work for LocationPath
> expressions
> > (http://www.w3.org/TR/xpath#NT-LocationPath), but I can't
> get it to work for
> > a FunctionCall expression
> (http://www.w3.org/TR/xpath#NT-FunctionCall).  So
> > If you try:
> >
> >     XPath xpath = myElem.createXPath( "bar:baz()" );
> >
> > or:
> >
> >     XPath xpath = DocumentFactory.getInstance.createXPath(
> "bar:baz()"
> > );
> >
> > you get an exception.  Is this a bug in the implementation?
> >
> > --
> > knut
> >
> >
> > > -----Original Message-----
> > > From: bob mcwhirter [mailto:[EMAIL PROTECTED]]
> > > Sent: Dienstag, 20. August 2002 17:09
> > > To: Wannheden, Knut
> > > Cc: '[EMAIL PROTECTED]'
> > > Subject: Re: [dom4j-user] [Q] How do I create an XPath with a
> > > NamespaceContext?
> > >
> > >
> > >
> > >   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
> > >
> >
>
> --
> 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
>

Reply via email to