Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Bug in Element.getNamespaceURI(String prefix)

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Laurent Bihanic <laurent.bihanic AT atosorigin.com>
  • To: XOM-interest <XOM-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] Bug in Element.getNamespaceURI(String prefix)
  • Date: Fri, 07 Feb 2003 12:25:54 +0100

Hi,

It is not possible to retrieve the default namespace URI using getNamespaceURI("") if the current element has at least one attribute not belong to any namespace.

The test case is the following:
<b xmlns="urn:x-xom:b" id="b">
<c:c xmlns:c="urn:x-xom:c" id="c" />
</b>

Invoking getNamespaceURI("") on element "b" returns "urn:x-xom:b" but invoking getNamespaceURI("") on element "c" returns "".

The problem lies in getLocalNamespaceURI() while scanning attribute namespaces. This method should makes a special case for the empty prefix and avoid checking attribute namespaces in this case.

Another problem is the way to handle null prefixes. XOM is not consistent here as some methods check against null prefixes and assume "" (Namespaces.remove()) while others (getLocalNamespaceURI()) do not check and throw NullPointerExceptions.

Laurent





Archive powered by MHonArc 2.6.24.

Top of Page