I have (finally) introduced explicit registration of namespace prefixes in the expression context. Sorry it took so long.
You can now register prefix/namespace pairs with JXPathContext using the registerNamespace() and/or setNamespaceContextPointer() methods. Please let me know if my fixes indeed work for you. I plan to do a bunch more testing of the new functionality in the next few days. - Dmitri ----- Original Message ----- From: <[EMAIL PROTECTED]> To: "Jakarta Commons Users List" <[EMAIL PROTECTED]> Cc: "Jakarta Commons Users List" <[EMAIL PROTECTED]> Sent: Thursday, March 18, 2004 4:28 AM Subject: Re: [JXPath] Namespace prefixes > > > > > > Eternal fame and gratitude will be yours :) > > Thank you, > > Nick > > "Dmitri Plotnikov" <[EMAIL PROTECTED]> wrote on 18/03/2004 06:11:23: > > > I'll re-introduce the NamespaceManager in a couple of days. I needed to > > collect more information as I did not quite understand the requirement. I > do > > now. Thank you very much for your help. > > > > - Dmitri > > > > ----- Original Message ----- > > From: <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, March 17, 2004 11:16 AM > > Subject: [JXPath] Namespace prefixes > > > > Hi, > > > > > > I'm having the same problem as Sudhir a while ago. > > > > http://www.mail-archive.com/[EMAIL PROTECTED]/msg05586.html > > > > > > He posted a good example that I'll repeat here: > > > > > > I have a fairly simple xml document: > > > > > > <?xml version="1.0"?> > > > <bk:book xmlns:bk='urn:loc.gov:books' > > > xmlns:isbn='urn:ISBN:0-395-36341-6'> > > > <bk:title>Cheaper by the Dozen</bk:title> > > > <isbn:number>1568491379</isbn:number> > > > </bk:book> > > > > > > To access say the isbn number I would use the following xpath in my > > > code. > > > /bk:book/isbn:number > > > > > > Note that I need to specify the prefixes in my xpath or it won't > work. > > > > > > Now if I had instead the following document which is identical for > all > > > practical purposes with the earlier xml except that the prefixes are > > > different, it is my opinion that my code still ought to work. > > > > > > <?xml version="1.0"?> > > > <ck:book xmlns:ck='urn:loc.gov:books' > > > xmlns:idn='urn:ISBN:0-395-36341-6'> > > > <ck:title>Cheaper by the Dozen</ck:title> > > > <idn:number>1568491379</idn:number> > > > </ck:book> > > > > > > But it doesn't. And that is because the prefixes I am specifying in > my > > > xpaths are not the same as what is used in the document. > > > > > > Dmitri implemented a NamespaceManager which would be a good solution to > > the > > > problem, but his patch got reversed. > > > > > > The problem remains however. > > > > > > Another less intrusive solution would be a setNamespace(String prefix, > > > String URI) function on a JXPathContext object. > > > This way all functionality that's present in Xalan is present in > JXPath. > > > As for XPaths on Java-objects, you could ignore all namespaces or > disallow > > > namespace qualifiers. I don't know what happens today if you specify a > > > namespace, but the behaviour could stay thesame. > > > > > > I'd very much like this namespace-prefix mapping feature to be > > > reconsidered, as currently JXPath isn't really usable for removing > silly > > > DOM-navigation-code when the Document uses namespaces. > > > > > > Nick Hofstede > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
