You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Glen Daniels <gl...@thoughtcraft.com> on 2007/03/24 15:52:15 UTC

[axiom] [axis2] getChildrenWithName() erroneous behavior

Hi all:

Currently OMElement.getChildrenWithName(QName) uses the 
OMChildrenQNameIterator to walk the list of children and return matches. 
  Here's the problem - if there is no namespace (or no localName... 
luckily that part isn't possible), the iterator will happily match ANY 
element with a matching localName.  So for instance when we do this:

config_element.getChildrenWithName(new QName("transportSender"))

We'll get both <axisCfg:transportSender> and 
<extension:transportSender>.  This is bad.  The above API call SHOULD 
only match <transportSender> in no namespace.

XML is namespace-aware, and our code should be too.  I'm going to change 
getChildrenWithName() to match using QName.equals().

If people really want a localname-only match, we can add something like 
OMElement.getChildrenWithLocalName(String), but it should be an 
explicitly different API.

Thoughts?

--Glen

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Glen Daniels <gl...@thoughtcraft.com>.
Done and done.

--G

David Illsley wrote:
> I'm +0.
> If you do it, however, please make sure you update the javadoc for
> OMContainer.getChildrenWithLocalName() [1].
> Thanks,
> David
> [1]  
> http://ws.apache.org/commons/axiom/apidocs/org/apache/axiom/om/OMContainer.html#getChildrenWithName(javax.xml.namespace.QName) 
> 
> 
> On 25/03/07, Sanjiva Weerawarana <sa...@opensource.lk> wrote:
>> +1.
>>
>> Glen Daniels wrote:
>> > Hi all:
>> >
>> > Currently OMElement.getChildrenWithName(QName) uses the
>> > OMChildrenQNameIterator to walk the list of children and return 
>> matches.
>> >  Here's the problem - if there is no namespace (or no localName...
>> > luckily that part isn't possible), the iterator will happily match ANY
>> > element with a matching localName.  So for instance when we do this:
>> >
>> > config_element.getChildrenWithName(new QName("transportSender"))
>> >
>> > We'll get both <axisCfg:transportSender> and
>> > <extension:transportSender>.  This is bad.  The above API call SHOULD
>> > only match <transportSender> in no namespace.
>> >
>> > XML is namespace-aware, and our code should be too.  I'm going to 
>> change
>> > getChildrenWithName() to match using QName.equals().
>> >
>> > If people really want a localname-only match, we can add something like
>> > OMElement.getChildrenWithLocalName(String), but it should be an
>> > explicitly different API.
>> >
>> > Thoughts?
>> >
>> > --Glen
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
>> > For additional commands, e-mail: axis-dev-help@ws.apache.org
>> >
>> >
>>
>> -- 
>> Sanjiva Weerawarana, Ph.D.
>> Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
>> Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
>> Director; Open Source Initiative; http://www.opensource.org/
>> Member; Apache Software Foundation; http://www.apache.org/
>> Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
>> For additional commands, e-mail: commons-dev-help@ws.apache.org
>>
>>
> 
> 

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


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by David Illsley <da...@gmail.com>.
I'm +0.
If you do it, however, please make sure you update the javadoc for
OMContainer.getChildrenWithLocalName() [1].
Thanks,
David
[1]  http://ws.apache.org/commons/axiom/apidocs/org/apache/axiom/om/OMContainer.html#getChildrenWithName(javax.xml.namespace.QName)

On 25/03/07, Sanjiva Weerawarana <sa...@opensource.lk> wrote:
> +1.
>
> Glen Daniels wrote:
> > Hi all:
> >
> > Currently OMElement.getChildrenWithName(QName) uses the
> > OMChildrenQNameIterator to walk the list of children and return matches.
> >  Here's the problem - if there is no namespace (or no localName...
> > luckily that part isn't possible), the iterator will happily match ANY
> > element with a matching localName.  So for instance when we do this:
> >
> > config_element.getChildrenWithName(new QName("transportSender"))
> >
> > We'll get both <axisCfg:transportSender> and
> > <extension:transportSender>.  This is bad.  The above API call SHOULD
> > only match <transportSender> in no namespace.
> >
> > XML is namespace-aware, and our code should be too.  I'm going to change
> > getChildrenWithName() to match using QName.equals().
> >
> > If people really want a localname-only match, we can add something like
> > OMElement.getChildrenWithLocalName(String), but it should be an
> > explicitly different API.
> >
> > Thoughts?
> >
> > --Glen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> > For additional commands, e-mail: axis-dev-help@ws.apache.org
> >
> >
>
> --
> Sanjiva Weerawarana, Ph.D.
> Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
> Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
> Director; Open Source Initiative; http://www.opensource.org/
> Member; Apache Software Foundation; http://www.apache.org/
> Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: commons-dev-help@ws.apache.org
>
>


-- 
David Illsley - IBM Web Services Development

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


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
+1.

Glen Daniels wrote:
> Hi all:
> 
> Currently OMElement.getChildrenWithName(QName) uses the 
> OMChildrenQNameIterator to walk the list of children and return matches. 
>  Here's the problem - if there is no namespace (or no localName... 
> luckily that part isn't possible), the iterator will happily match ANY 
> element with a matching localName.  So for instance when we do this:
> 
> config_element.getChildrenWithName(new QName("transportSender"))
> 
> We'll get both <axisCfg:transportSender> and 
> <extension:transportSender>.  This is bad.  The above API call SHOULD 
> only match <transportSender> in no namespace.
> 
> XML is namespace-aware, and our code should be too.  I'm going to change 
> getChildrenWithName() to match using QName.equals().
> 
> If people really want a localname-only match, we can add something like 
> OMElement.getChildrenWithLocalName(String), but it should be an 
> explicitly different API.
> 
> Thoughts?
> 
> --Glen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
> 
> 

-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/

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


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Glen Daniels <gl...@thoughtcraft.com>.
Hi Chinthaka!

Eran Chinthaka wrote:
>> Currently OMElement.getChildrenWithName(QName) uses the
>> OMChildrenQNameIterator to walk the list of children and return matches.
>>  Here's the problem - if there is no namespace (or no localName...
>> luckily that part isn't possible), the iterator will happily match ANY
>> element with a matching localName.  So for instance when we do this:
>>
>> config_element.getChildrenWithName(new QName("transportSender"))
>>
>> We'll get both <axisCfg:transportSender> and
>> <extension:transportSender>.  This is bad.  The above API call SHOULD
>> only match <transportSender> in no namespace.
> 
> I did this purposely and I wanted to get matching nodes when I am not
> sure about the namespace. The idea I had in mind was, say if I have a
> SOAP message and and if I wanted to see whether the body contains a
> fault, then I can use the above method without worrying about which
> version of SOAP I am dealing with.

Unfortunately, XML is namespace aware, and if you're going to be using 
it, ESPECIALLY as the author of infrastructure code that is expected to 
be industrial-strength, you need to be rigorous about namespaces.  If 
you wrote code like you describe and got this:

<soap:Envelope>
   <soap:Body>
     <myGeologyApp:Fault name="San Andreas">
       <customData/>
     </myGeologyApp:Fault>
   </soap:Body>
</soap:Envelope>

...then that would be recognized as a SOAP fault (which wouldn't parse 
right anyway) and your poor user might not ever be able to receive their 
geological information.  There were a LOT of problems that were hidden 
in OM because of this kind of non-namespace-aware comparison.

> But if you want to clean this method and create another method, I'm ok
> with that too. But please please make sure we have
> OMElement.getChildrenWithLocalName(String). I am a poor user which needs
> that.

Sure, but our code really shouldn't be using it... :)

--Glen

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


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Glen Daniels <gl...@thoughtcraft.com>.
Hi Chinthaka!

Eran Chinthaka wrote:
>> Currently OMElement.getChildrenWithName(QName) uses the
>> OMChildrenQNameIterator to walk the list of children and return matches.
>>  Here's the problem - if there is no namespace (or no localName...
>> luckily that part isn't possible), the iterator will happily match ANY
>> element with a matching localName.  So for instance when we do this:
>>
>> config_element.getChildrenWithName(new QName("transportSender"))
>>
>> We'll get both <axisCfg:transportSender> and
>> <extension:transportSender>.  This is bad.  The above API call SHOULD
>> only match <transportSender> in no namespace.
> 
> I did this purposely and I wanted to get matching nodes when I am not
> sure about the namespace. The idea I had in mind was, say if I have a
> SOAP message and and if I wanted to see whether the body contains a
> fault, then I can use the above method without worrying about which
> version of SOAP I am dealing with.

Unfortunately, XML is namespace aware, and if you're going to be using 
it, ESPECIALLY as the author of infrastructure code that is expected to 
be industrial-strength, you need to be rigorous about namespaces.  If 
you wrote code like you describe and got this:

<soap:Envelope>
   <soap:Body>
     <myGeologyApp:Fault name="San Andreas">
       <customData/>
     </myGeologyApp:Fault>
   </soap:Body>
</soap:Envelope>

...then that would be recognized as a SOAP fault (which wouldn't parse 
right anyway) and your poor user might not ever be able to receive their 
geological information.  There were a LOT of problems that were hidden 
in OM because of this kind of non-namespace-aware comparison.

> But if you want to clean this method and create another method, I'm ok
> with that too. But please please make sure we have
> OMElement.getChildrenWithLocalName(String). I am a poor user which needs
> that.

Sure, but our code really shouldn't be using it... :)

--Glen

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Eran Chinthaka <ch...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,



Glen Daniels wrote:
> Hi all:
> 
> Currently OMElement.getChildrenWithName(QName) uses the
> OMChildrenQNameIterator to walk the list of children and return matches.
>  Here's the problem - if there is no namespace (or no localName...
> luckily that part isn't possible), the iterator will happily match ANY
> element with a matching localName.  So for instance when we do this:
> 
> config_element.getChildrenWithName(new QName("transportSender"))
> 
> We'll get both <axisCfg:transportSender> and
> <extension:transportSender>.  This is bad.  The above API call SHOULD
> only match <transportSender> in no namespace.

I did this purposely and I wanted to get matching nodes when I am not
sure about the namespace. The idea I had in mind was, say if I have a
SOAP message and and if I wanted to see whether the body contains a
fault, then I can use the above method without worrying about which
version of SOAP I am dealing with.

But if you want to clean this method and create another method, I'm ok
with that too. But please please make sure we have
OMElement.getChildrenWithLocalName(String). I am a poor user which needs
that.

Thanks,
Chinthaka
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEeurjON2uBzUhh8RAgRUAJwIm0ZvAg2a+lS+1HrtISinHivcngCcDFSo
tkZktx6rum7LcbNbnklabLk=
=i/C7
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Eran Chinthaka <ch...@opensource.lk>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,



Glen Daniels wrote:
> Hi all:
> 
> Currently OMElement.getChildrenWithName(QName) uses the
> OMChildrenQNameIterator to walk the list of children and return matches.
>  Here's the problem - if there is no namespace (or no localName...
> luckily that part isn't possible), the iterator will happily match ANY
> element with a matching localName.  So for instance when we do this:
> 
> config_element.getChildrenWithName(new QName("transportSender"))
> 
> We'll get both <axisCfg:transportSender> and
> <extension:transportSender>.  This is bad.  The above API call SHOULD
> only match <transportSender> in no namespace.

I did this purposely and I wanted to get matching nodes when I am not
sure about the namespace. The idea I had in mind was, say if I have a
SOAP message and and if I wanted to see whether the body contains a
fault, then I can use the above method without worrying about which
version of SOAP I am dealing with.

But if you want to clean this method and create another method, I'm ok
with that too. But please please make sure we have
OMElement.getChildrenWithLocalName(String). I am a poor user which needs
that.

Thanks,
Chinthaka
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGEeurjON2uBzUhh8RAgRUAJwIm0ZvAg2a+lS+1HrtISinHivcngCcDFSo
tkZktx6rum7LcbNbnklabLk=
=i/C7
-----END PGP SIGNATURE-----

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


Re: [axiom] [axis2] getChildrenWithName() erroneous behavior

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
+1.

Glen Daniels wrote:
> Hi all:
> 
> Currently OMElement.getChildrenWithName(QName) uses the 
> OMChildrenQNameIterator to walk the list of children and return matches. 
>  Here's the problem - if there is no namespace (or no localName... 
> luckily that part isn't possible), the iterator will happily match ANY 
> element with a matching localName.  So for instance when we do this:
> 
> config_element.getChildrenWithName(new QName("transportSender"))
> 
> We'll get both <axisCfg:transportSender> and 
> <extension:transportSender>.  This is bad.  The above API call SHOULD 
> only match <transportSender> in no namespace.
> 
> XML is namespace-aware, and our code should be too.  I'm going to change 
> getChildrenWithName() to match using QName.equals().
> 
> If people really want a localname-only match, we can add something like 
> OMElement.getChildrenWithLocalName(String), but it should be an 
> explicitly different API.
> 
> Thoughts?
> 
> --Glen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-dev-help@ws.apache.org
> 
> 

-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org