ws-soap-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From duft...@us.ibm.com
Subject Re: Fw: Xerces 1.1.2 Bug
Date Wed, 19 Jul 2000 14:03:03 GMT
>The DOM's getAttributeNS() method behaves like getAttribute().

Not according to the apiDocs. They state that the exact opposite is true.
When I said it was a bug, I meant as per the api docs that accompany the
distribution. I believe this is what the other folks who encountered this
meant also. The following is from the apiDocs for
Element.getAttributeNS(...).


getAttributeNS

public java.lang.String getAttributeNS(java.lang.String namespaceURI,
                                       java.lang.String localName)

     Retrieves an attribute value by local name and namespace URI.
HTML-only DOM implementations do not need to implement this method.
     Parameters:
          namespaceURI - The namespace URI of the attribute to retrieve.
          localName - The local name of the attribute to retrieve.
     Returns:
          The Attr value as a string, or an null if that attribute does not
have a specified or default value. This is different from getAttribute
which never return null .
     Since:
          DOM Level 2

Joseph Kesselman/Watson/IBM@IBMUS on 07/19/2000 09:00:48 AM

Please respond to soap-user@xml.apache.org

To:   "Sanjiva Weerawarana" <sanjiva@watson.ibm.com>
cc:   Mike Pogue/Cupertino/IBM@IBMUS, Matthew Duftler/Watson/IBM@IBMUS,
      Andy Clark/Austin/Contr/IBM@IBMUS, soap-dev@xml.apache.org,
      soap-user@xml.apache.org
Subject:  Re: Fw: Xerces 1.1.2 Bug



The described behavior is not a bug, per the DOM Level 2 Candidate
Recommendation.

The DOM's getAttributeNS() method behaves like getAttribute(). If an
attribute is not present and doesn't have a default value, it should return
an empty string.

If you want to distinguish this case, use getAttributeNodeNS() to obtain
the Attr object; this returns null if there isn't one.

You can obtain the requested behavior by saying something like:

     Attr tempAttr;
     String valueOrNull = ( (tempAttr=myNode.getAttributeNodeNS(...)) ==
null )
               : null
               ? tempAttr.getNodeValue();

(We can, and do, argue about whether having getAttribute return an empty
string was a good idea or not. But that decision was made in DOM Level 1,
and we decided that the new namespace-aware methods in Level 2 should
follow that behavior to avoid confusing users faimilar with the Level 1
calls.)

______________________________________
Joe Kesselman  / IBM Research






Mime
View raw message