You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2001/03/31 00:43:49 UTC
[Bug 1164] New - ElementNSImpl.getNamespaceURI() returns "" instead of null
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1164
*** shadow/1164 Fri Mar 30 14:43:49 2001
--- shadow/1164.tmp.20630 Fri Mar 30 14:43:49 2001
***************
*** 0 ****
--- 1,71 ----
+ +============================================================================+
+ | ElementNSImpl.getNamespaceURI() returns "" instead of null |
+ +----------------------------------------------------------------------------+
+ | Bug #: 1164 Product: Xerces-J |
+ | Status: NEW Version: 1.3.1 |
+ | Resolution: Platform: PC |
+ | Severity: Normal OS/Version: Other |
+ | Priority: Component: DOM |
+ +----------------------------------------------------------------------------+
+ | Assigned To: xerces-j-dev@xml.apache.org |
+ | Reported By: czhao@commonvision.com |
+ | CC list: Cc: |
+ +----------------------------------------------------------------------------+
+ | URL: |
+ +============================================================================+
+ | DESCRIPTION |
+ When an element name does not have namespace, ElementNSImpl.getNamespaceURI()
+ returns null in 1.2.3, but it returns "" in 1.3.1. Test case:
+
+ dummy.xml:
+ ----------------------
+ <?xml version='1.0'?>
+ <x:foo xmlns:x='http://foo.com'>
+ <bar> blar </bar>
+ </x:foo>
+
+ TestNamespace.java:
+ ----------------------
+ import org.apache.xerces.parsers.*;
+ import org.apache.xerces.dom.*;
+ import org.w3c.dom.*;
+ import org.xml.sax.*;
+
+ public class TestNamespace {
+ public static void main(String[] argv) {
+ try {
+ DOMParser parser = new DOMParser();
+ parser.setFeature
+ ("http://xml.org/sax/features/namespaces", true);
+ parser.parse(new InputSource(new java.io.FileReader
+ ("d:/test/soap/dummy.xml")));
+ Document doc = parser.getDocument();
+ ElementNSImpl foo = (ElementNSImpl)
+ doc.getDocumentElement();
+ Node node = foo.getFirstChild();
+ while (node.getNodeType() != Node.ELEMENT_NODE) {
+ node = node.getNextSibling();
+ }
+ ElementNSImpl bar = (ElementNSImpl) node;
+ System.out.println("foo NamespaceURI:
+ *"+foo.getNamespaceURI()+"*");
+ System.out.println("foo LocalName: *"+foo.getLocalName()
+ +"*");
+ System.out.println("bar NamespaceURI:
+ *"+bar.getNamespaceURI()+"*");
+ System.out.println("bar LocalName: *"+bar.getLocalName()
+ +"*");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ 1.2.3 returns:
+ bar NamespaceURI: *null*
+
+ 1.3.1 returns:
+ bar NamespaceURI: **
+
+ This behavior breaks codes in Soap 2.1 that only test namespaceURI for null but
+ does not test it for "".
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org