On Thu, 2005-12-22 at 16:50 +0600, Ruchith Fernando wrote:
> Hi Azeez,
> 
> This is a known issue in serializing *unqualified* xml elements.

First of all, IIRC the test envelope is wrong: children of <soap:Body>
*must* be qualified. 

However, that does not excuse the NPE behavior :).

> org.apache.axis2.om.impl.llom.OMSerializerUtil was originally written
> to only work with LLOM OM implementation. And it uses getLocalName()
> of OMElement to get the local part of a qualified element OR the 'tag
> name' of a qualified element.

OK. (You meant "unqualified" in the last bit there I believe.)

> And now DOOM uses it to serialize DOOM elements. But according to the
> DOM APIs[1] (Proof: [2]) the when getLocalName() is called on an
> unqualified element it will be null. And DOOM does this properly to
> comply with DOM interfaces.

I just looked thru the DOM L2 spec [1] and AFAICT the behavior is not
clearly defined. In particular, it says: 

"localName of type DOMString, readonly, introduced in DOM Level 2
        Returns the local part of the qualified name of this node.
        For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE
        and nodes created with a DOM Level 1 method, such as
        createElement from the Document interface, this is always null".

Note that it does not say what happens if the name was not qualified at
all. There's further discussion of namespace issues in [2] but that does
not clarify it either. So, at least to me, it appears that you're
noticing the behavior of the default DOM impl rather than spec
compliance.

> Therefore we have two options to solve this problem:
>     1.) Modify OMSerializerUtil to check for whether the element being
> serialized is a DOM element by checking instanceof org.w3c.Element and
> calling getTagName if the element is not namespace qualified.
> 
>     2.) Add another method to OMElement interface : public String
> getTagName() where we can use it in the case when we serialize an
> unqualified element (either LLOM or DOOM).
> 
> What do you think?

If the spec indeed does not specify a given behavior, my preference
would be to change getLocalName() to return the name if the OMElement is
unqualified. 

Sanjiva.
[1] http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html
[2]
http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#Namespaces-Considerations


Reply via email to