You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dmitri Plotnikov <dm...@apache.org> on 2004/04/01 04:58:10 UTC

Re: [JXPath] Namespace prefixes

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: <Ni...@inventivedesigners.com>
To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
Cc: "Jakarta Commons Users List" <co...@jakarta.apache.org>
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" <dm...@apache.org> 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: <Ni...@inventivedesigners.com>
> > To: <co...@jakarta.apache.org>
> > 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/commons-user@jakarta.apache.org/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: 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


Re: [JXPath] Namespace prefixes

Posted by Ni...@inventivedesigners.com.




The API looks good, I'll be testing this in the next few days as well and
will let you know if I encounter any problem.

Thank you,

Nick Hofstede

"Dmitri Plotnikov" <dm...@apache.org> wrote on 01/04/2004 04:58:10:

> 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: <Ni...@inventivedesigners.com>
> To: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> Cc: "Jakarta Commons Users List" <co...@jakarta.apache.org>
> 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" <dm...@apache.org> 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: <Ni...@inventivedesigners.com>
> > > To: <co...@jakarta.apache.org>
> > > 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/commons-user@jakarta.apache.org/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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org