You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2007/03/09 05:26:23 UTC

svn commit: r516291 - in /xerces/java/trunk/src/org/apache: wml/dom/WMLDOMImplementationImpl.java xerces/dom/CoreDOMImplementationImpl.java xerces/dom/DOMImplementationImpl.java xerces/dom/PSVIDOMImplementationImpl.java

Author: mrglavas
Date: Thu Mar  8 20:26:22 2007
New Revision: 516291

URL: http://svn.apache.org/viewvc?view=rev&rev=516291
Log:
Fixing JIRA Bug #1234:
https://issues.apache.org/jira/browse/XERCESJ-1234

If DOMImplementation.createDocument() is called with a null namespaceURI 
and qualifiedName it's supposed to return an empty Document.

Modified:
    xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java
    xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java

Modified: xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java?view=diff&rev=516291&r1=516290&r2=516291
==============================================================================
--- xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/wml/dom/WMLDOMImplementationImpl.java Thu Mar  8 20:26:22 2007
@@ -14,11 +14,18 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.wml.dom;
 
-import org.apache.wml.*;
-import org.w3c.dom.*;
-import org.apache.xerces.dom.*;
+import org.apache.wml.WMLDOMImplementation;
+import org.apache.xerces.dom.DOMImplementationImpl;
+import org.apache.xerces.dom.DOMMessageFormatter;
+import org.apache.xerces.dom.DocumentImpl;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentType;
+import org.w3c.dom.Element;
 
 /**
  * @xerces.internal
@@ -40,10 +47,18 @@
     public Document createDocument(String namespaceURI, 
             String qualifiedName, 
             DocumentType doctype) throws DOMException {
+        if (doctype != null && doctype.getOwnerDocument() != null) {
+            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, 
+                                   DOMMessageFormatter.formatMessage(
+                                   DOMMessageFormatter.XML_DOMAIN, 
+                                   "WRONG_DOCUMENT_ERR", null));
+        }
         DocumentImpl doc = new WMLDocumentImpl(doctype);
-        //((DocumentTypeImpl)doctype).ownerDocument = doc;
-        Element e = doc.createElementNS( namespaceURI, qualifiedName);
-        doc.appendChild(e);
+        // If namespaceURI and qualifiedName are null return a Document with no document element.
+        if (qualifiedName != null || namespaceURI != null) {
+            Element e = doc.createElementNS(namespaceURI, qualifiedName);
+            doc.appendChild(e);
+        }
         return doc;
     }
 }

Modified: xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java?view=diff&rev=516291&r1=516290&r2=516291
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/CoreDOMImplementationImpl.java Thu Mar  8 20:26:22 2007
@@ -286,8 +286,11 @@
 			throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
 		}
 		CoreDocumentImpl doc = new CoreDocumentImpl(doctype);
-		Element e = doc.createElementNS(namespaceURI, qualifiedName);
-		doc.appendChild(e);
+		// If namespaceURI and qualifiedName are null return a Document with no document element.
+		if (qualifiedName != null || namespaceURI != null) {
+		    Element e = doc.createElementNS(namespaceURI, qualifiedName);
+		    doc.appendChild(e);
+		}
 		return doc;
 	}
 

Modified: xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java?view=diff&rev=516291&r1=516290&r2=516291
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DOMImplementationImpl.java Thu Mar  8 20:26:22 2007
@@ -130,18 +130,16 @@
                                              DocumentType doctype)
                                              throws DOMException
     {
-        if(namespaceURI == null && qualifiedName == null && doctype == null){
-        //if namespaceURI, qualifiedName and doctype are null, returned document is empty with
-        //no document element
-            return new DocumentImpl();
-        }
-    	else if (doctype != null && doctype.getOwnerDocument() != null) {
+        if (doctype != null && doctype.getOwnerDocument() != null) {
             String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
             throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
         }
         DocumentImpl doc = new DocumentImpl(doctype);
-        Element e = doc.createElementNS( namespaceURI, qualifiedName);
-        doc.appendChild(e);
+        // If namespaceURI and qualifiedName are null return a Document with no document element.
+        if (qualifiedName != null || namespaceURI != null) {
+            Element e = doc.createElementNS(namespaceURI, qualifiedName);
+            doc.appendChild(e);
+        }
         return doc;
     }
 

Modified: xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java?view=diff&rev=516291&r1=516290&r2=516291
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/PSVIDOMImplementationImpl.java Thu Mar  8 20:26:22 2007
@@ -113,8 +113,11 @@
 					               "WRONG_DOCUMENT_ERR", null));
         }
         DocumentImpl doc = new PSVIDocumentImpl(doctype);
-        Element e = doc.createElementNS( namespaceURI, qualifiedName);
-        doc.appendChild(e);
+        // If namespaceURI and qualifiedName are null return a Document with no document element.
+        if (qualifiedName != null || namespaceURI != null) {
+            Element e = doc.createElementNS(namespaceURI, qualifiedName);
+            doc.appendChild(e);
+        }
         return doc;
     }
     



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org