You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ne...@apache.org on 2003/10/29 11:25:47 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/dom DOMImplementationImpl.java

neeraj      2003/10/29 02:25:47

  Modified:    java/src/org/apache/xerces/dom DOMImplementationImpl.java
  Log:
  Fixing Bug. If the NamespaceURI, qualifiedName and doctype are null,
  the returned Document is empty with no document element.
  
  Revision  Changes    Path
  1.28      +30 -25    xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java
  
  Index: DOMImplementationImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/DOMImplementationImpl.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- DOMImplementationImpl.java	10 Jun 2003 18:09:38 -0000	1.27
  +++ DOMImplementationImpl.java	29 Oct 2003 10:25:47 -0000	1.28
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights 
  + * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
    *    Alternately, this acknowledgment may appear in the software itself,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "Xerces" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -78,7 +78,7 @@
    * @version $Id$
    * @since  PR-DOM-Level-1-19980818.
    */
  -public class DOMImplementationImpl extends CoreDOMImplementationImpl 
  +public class DOMImplementationImpl extends CoreDOMImplementationImpl
       implements DOMImplementation {
   
       //
  @@ -98,16 +98,16 @@
       /** NON-DOM: Obtain and return the single shared object */
       public static DOMImplementation getDOMImplementation() {
           return singleton;
  -    }  
  +    }
   
       //
       // DOMImplementation methods
       //
   
  -    /** 
  +    /**
        * Test if the DOM implementation supports a specific "feature" --
        * currently meaning language and level thereof.
  -     * 
  +     *
        * @param feature      The package name of the feature to test.
        * In Level 1, supported values are "HTML" and "XML" (case-insensitive).
        * At this writing, org.apache.xerces.dom supports only XML.
  @@ -123,7 +123,7 @@
   
           // Currently, we support only XML Level 1 version 1.0
           boolean anyVersion = version == null || version.length() == 0;
  -		// check if Xalan implementation is around and if yes report true for supporting 
  +		// check if Xalan implementation is around and if yes report true for supporting
   		// XPath API
   		if ((feature.equalsIgnoreCase("XPath") || feature.equalsIgnoreCase("+XPath"))&& version.equals("3.0")){
   			try{
  @@ -136,43 +136,43 @@
   			}
   			return true;
   		}
  -        return 
  -            (feature.equalsIgnoreCase("Core") 
  +        return
  +            (feature.equalsIgnoreCase("Core")
               && (anyVersion
   		|| version.equals("1.0")
   		|| version.equals("2.0")))
  -         || (feature.equalsIgnoreCase("XML") 
  +         || (feature.equalsIgnoreCase("XML")
               && (anyVersion
   		|| version.equals("1.0")
   		|| version.equals("2.0")))
  -         || (feature.equalsIgnoreCase("Events") 
  +         || (feature.equalsIgnoreCase("Events")
   	     && (anyVersion
   		 || version.equals("2.0")))
  -         || (feature.equalsIgnoreCase("MutationEvents") 
  +         || (feature.equalsIgnoreCase("MutationEvents")
   	     && (anyVersion
   		 || version.equals("2.0")))
  -         || (feature.equalsIgnoreCase("Traversal") 
  +         || (feature.equalsIgnoreCase("Traversal")
   	     && (anyVersion
   		 || version.equals("2.0")))
  -         || (feature.equalsIgnoreCase("Range") 
  +         || (feature.equalsIgnoreCase("Range")
   	     && (anyVersion
   		 || version.equals("2.0")))
               ;
   
       } // hasFeature(String,String):boolean
   
  -    
  +
   
       /**
        * Introduced in DOM Level 2. <p>
  -     * 
  +     *
        * Creates an XML Document object of the specified type with its document
        * element.
        *
        * @param namespaceURI     The namespace URI of the document
  -     *                         element to create, or null. 
  +     *                         element to create, or null.
        * @param qualifiedName    The qualified name of the document
  -     *                         element to create. 
  +     *                         element to create.
        * @param doctype          The type of document to be created or null.<p>
        *
        *                         When doctype is not null, its
  @@ -183,12 +183,17 @@
        *                         already been used with a different document.
        * @since WD-DOM-Level-2-19990923
        */
  -    public Document           createDocument(String namespaceURI, 
  -                                             String qualifiedName, 
  +    public Document           createDocument(String namespaceURI,
  +                                             String qualifiedName,
                                                DocumentType doctype)
                                                throws DOMException
       {
  -    	if (doctype != null && doctype.getOwnerDocument() != null) {
  +        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) {
               String msg = DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "WRONG_DOCUMENT_ERR", null);
               throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, msg);
           }
  @@ -197,6 +202,6 @@
           doc.appendChild(e);
           return doc;
       }
  -    
  +
   
   } // class DOMImplementationImpl
  
  
  

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