commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dmitri Plotnikov" <dmi...@apache.org>
Subject Re: [jxpath] Namespace problem with 1.2
Date Sat, 14 Aug 2004 22:01:06 GMT
John,

Namespaces do not apply to objects, unless, of course, those objects are
handled by custom NodePointers that are made namespace-aware.  The standard
distribution of JXPath does not contain any such NodePointers.

As far as the interpretation of XPaths on XML documents is concerned, we are
bound by the XPath 1.0 standard.  On the other hand, the standard does not
say anything about applying XPaths to any non-XML object models, therefore
we were free to make pretty much arbitrary choices.  One of those choices
was to ignore namespaces.

Best,

- Dmitri


----- Original Message ----- 
From: "John E. Conlon" <jconlon@verticon.com>
To: "Dmitri Plotnikov" <dmitri@apache.org>
Cc: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
Sent: Saturday, August 14, 2004 3:53 PM
Subject: Re: [jxpath] Namespace problem with 1.2


> Dmitri,
>
> Yes, that worked for me. But, I previously treated objects and documents
> in the same way, but now documents XPaths require registering
> namespaces. I had to change my old code for this but it works.
>
> Do namespaces in any way apply to objects?
>
> regards,
> John
>
> Previously I was using
> On Thu, 2004-08-12 at 17:33, Dmitri Plotnikov wrote:
> > John,
> >
> > JXPath 1.2 handles namespaces somewhat differently from JXPath 1.1.  It
is
> > following the XPath specification more closely. The specification
describes
> > the procedure of matching a name by comparing so-called expanded names.
An
> > expanded name is a combination of a local name and a namespace URI.  In
your
> > particular case, the LDAP element in the document has the expanded name
> > ("LDAP", "http://www.verticon.com/react2/schema"), while the "LDAP" node
> > test expands to ("LDAP", null).
> >
> > Quote from the spec: "Two expanded-names are equal if they have the same
> > local part, and either both have a null namespace URI or both have
non-null
> > namespace URIs that are equal."
> >
> > The notion of default namespace applies to elements of an XML document,
but
> > does not apply to XPaths.  Quote: "if the QName does not have a prefix,
then
> > the namespace URI is null (this is the same way attribute names are
> > expanded). It is an error if the QName has a prefix for which there is
no
> > namespace declaration in the expression context [i.e. JXPathContext]."
> >
> > To remedy the situation, do the following two things:
> >
> > 1. Register the namespace with the JXPathContext:
> >
> >     context.registerNamespace("schema",
> > "http://www.verticon.com/react2/schema");
> >
> > 2. Use this prefix in your XPaths:
> >     context.getValue("//schema:LDAP")
> >
> > I hope this helps,
> >
> > - Dmitri
> >
> > ----- Original Message ----- 
> > From: "John E. Conlon" <jconlon@verticon.com>
> > To: <commons-user@jakarta.apache.org>
> > Sent: Wednesday, August 11, 2004 5:20 PM
> > Subject: [jxpath] Namespace problem with 1.2
> >
> >
> > > Have been using version 1.1 to manipulate XML documents using a
default
> > > namespace without any problems, but 1.2 doesn't work with my code.
> > >
> > > Here is a sample document:
> > >
> > > <?xml version = "1.0" encoding = "UTF-8"?>
> > > <Configuration xmlns = "http://www.verticon.com/react2/schema">
> > >       <URIObjectSource>
> > >         <LDAP>
> > >           <URIObjectDefinition implementation="flagpools"/>
> > >         </LDAP>
> > >       </URIObjectSource>
> > > </Configuration>
> > >
> > > With JXPath 1.1 I could use the a XPath "//LDAP" to get to the LDAP
node
> > > of this document, but with 1.2 I cannot.
> > >
> > > For example:
> > > JXPathContext context = JXPathContext.newContext(myDocument);
> > > Object o = context.getValue("//LDAP");
> > >
> > > JXPath 1.1 will return a value but 1.2 returns a null.
> > >
> > > Any ideas how I can get 1.2 working?
> > >
> > > John Conlon
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> > >
> > >
> > >
> > >
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message