Index: org/apache/xerces/dom/DOMConfigurationImpl.java
===================================================================
retrieving revision 1.28
diff -u -r1.28 DOMConfigurationImpl.java
--- org/apache/xerces/dom/DOMConfigurationImpl.java	14 Apr 2004 15:54:06 -0000	1.28
+++ org/apache/xerces/dom/DOMConfigurationImpl.java	7 May 2004 15:19:27 -0000
@@ -148,8 +148,9 @@
     protected final static short VALIDATE            = 0x1<<6;
     protected final static short PSVI                = 0x1<<7;
     protected final static short WELLFORMED          = 0x1<<8;
+    protected final static short NSDECL              = 0x1<<9;
 
-    protected final static short INFOSET_TRUE_PARAMS = NAMESPACES | COMMENTS | WELLFORMED;
+    protected final static short INFOSET_TRUE_PARAMS = NAMESPACES | COMMENTS | WELLFORMED | NSDECL;
     protected final static short INFOSET_FALSE_PARAMS = ENTITIES | DTNORMALIZATION | CDATA;
     protected final static short INFOSET_MASK = INFOSET_TRUE_PARAMS | INFOSET_FALSE_PARAMS;
 
@@ -254,7 +255,8 @@
         features |= COMMENTS;
         features |= CDATA;
         features |= SPLITCDATA;
-        features |=  WELLFORMED;
+        features |= WELLFORMED;
+        features |= NSDECL;
 
         if (symbolTable == null) {
             symbolTable = new SymbolTable();
@@ -544,6 +546,9 @@
             else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
                 features = (short) (state ? features | WELLFORMED : features & ~WELLFORMED );
             }
+            else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+                features = (short) (state ? features | NSDECL : features & ~NSDECL);
+            }
             else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
                 // Setting to false has no effect.
                 if (state) {
@@ -566,8 +571,7 @@
                     throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                 }
             }
-            else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
-                    || name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
+			else if ( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
                 if (!state) { // false is not supported
                     String msg =
                         DOMMessageFormatter.formatMessage(
@@ -576,7 +580,6 @@
                             new Object[] { name });
                    throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                 }
-
             }
             else if (name.equalsIgnoreCase(SEND_PSVI) ){
                 // REVISIT: turning augmentation of PSVI is not support,
@@ -788,6 +791,9 @@
 		else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
 			return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
 		}
+		else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+		    return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;
+		} 
 		else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)) {
 			return (features & INFOSET_MASK) == INFOSET_TRUE_PARAMS ? Boolean.TRUE : Boolean.FALSE;
 		}
@@ -803,10 +809,8 @@
         }
         else if (name.equalsIgnoreCase(Constants.DOM_PSVI)) {
             return (features & PSVI) != 0 ? Boolean.TRUE : Boolean.FALSE;
-        }
-		else if (
-			name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
-				|| name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
+        }		
+        else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)) {
 			return Boolean.TRUE;
 		}
 		else if (name.equalsIgnoreCase(Constants.DOM_ERROR_HANDLER)) {
@@ -879,8 +883,9 @@
                 || name.equalsIgnoreCase(Constants.DOM_VALIDATE)
                 || name.equalsIgnoreCase(Constants.DOM_WELLFORMED)
                 || name.equalsIgnoreCase(Constants.DOM_INFOSET)
+                || name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
                 ) {
-                return true ;
+                return true;
             }//features whose parameter value can not be set to 'true'
             else if (
                 name.equalsIgnoreCase(Constants.DOM_NORMALIZE_CHARACTERS)
@@ -890,8 +895,7 @@
                     ) {
                     return (value.equals(Boolean.TRUE)) ? false : true;
             }//features whose parameter value can not be set to 'false'
-            else if( name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
-                    || name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
+            else if( name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
                     || name.equalsIgnoreCase(SEND_PSVI)
                     ) {
                     return (value.equals(Boolean.TRUE)) ? true : false;
Index: org/apache/xerces/dom/DOMNormalizer.java
===================================================================
retrieving revision 1.54
diff -u -r1.54 DOMNormalizer.java
--- org/apache/xerces/dom/DOMNormalizer.java	22 Apr 2004 20:39:03 -0000	1.54
+++ org/apache/xerces/dom/DOMNormalizer.java	7 May 2004 15:19:27 -0000
@@ -297,6 +297,18 @@
                     // normalize attribute values
                     // remove default attributes
                     namespaceFixUp(elem, attributes);
+                    
+                    if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0 && attributes != null ) {
+                        for (int i = 0; i < attributes.getLength(); ++i) {
+                            Attr att = (Attr)attributes.getItem(i);
+                            if (XMLSymbols.PREFIX_XMLNS.equals(att.getPrefix()) ||
+                                XMLSymbols.PREFIX_XMLNS.equals(att.getName())) {
+                                elem.removeAttributeNode(att);
+                                --i;
+                            }
+                        }
+                    }  
+                    
                 } else {
                     if ( attributes!=null ) {
                         for ( int i=0; i<attributes.getLength(); ++i ) {
Index: org/apache/xerces/parsers/DOMParserImpl.java
===================================================================
retrieving revision 1.25
diff -u -r1.25 DOMParserImpl.java
--- org/apache/xerces/parsers/DOMParserImpl.java	23 Apr 2004 16:06:10 -0000	1.25
+++ org/apache/xerces/parsers/DOMParserImpl.java	7 May 2004 15:19:28 -0000
@@ -33,7 +33,11 @@
 import org.apache.xerces.util.DOMEntityResolverWrapper;
 import org.apache.xerces.util.DOMErrorHandlerWrapper;
 import org.apache.xerces.util.SymbolTable;
+import org.apache.xerces.util.XMLSymbols;
 import org.apache.xerces.xni.grammars.XMLGrammarPool;
+import org.apache.xerces.xni.Augmentations;
+import org.apache.xerces.xni.QName;
+import org.apache.xerces.xni.XMLAttributes;
 import org.apache.xerces.xni.parser.XMLConfigurationException;
 import org.apache.xerces.xni.parser.XMLEntityResolver;
 import org.apache.xerces.xni.parser.XMLInputSource;
@@ -103,7 +107,9 @@
     // Data
     //
 
-
+    /** Include namespace declaration attributes in the document. **/
+    protected boolean fNamespaceDeclarations = true;
+    
     // REVISIT: this value should be null by default and should be set during creation of
     //          LSParser
     protected String fSchemaType = null;
@@ -130,9 +136,11 @@
         configuration));
         if (schemaType != null) {
             if (schemaType.equals (Constants.NS_DTD)) {
-                fConfiguration.setFeature (
-                Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE,
-                false);
+                //Schema validation is false by default and hence there is no
+                //need to set it to false here.  Also, schema validation is  
+                //not a recognized feature for DTDConfiguration's and so 
+                //setting this feature here would result in a Configuration 
+                //Exception.            
                 fConfiguration.setProperty (
                 Constants.JAXP_PROPERTY_PREFIX + Constants.SCHEMA_LANGUAGE,
                 Constants.NS_DTD);
@@ -187,10 +195,9 @@
         fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
         fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
         fConfiguration.setFeature(NAMESPACES, true);
-
+		
         fConfiguration.setFeature(DYNAMIC_VALIDATION, false);
         fConfiguration.setFeature(CREATE_ENTITY_REF_NODES, false);
-        fConfiguration.setFeature(NORMALIZE_DATA, false);
         fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, false);
 
         // set other default values
@@ -205,7 +212,13 @@
         fConfiguration.setFeature (Constants.DOM_CERTIFIED, true);
 
         // Xerces datatype-normalization feature is on by default
-        fConfiguration.setFeature ( NORMALIZE_DATA, false );
+        // This is a recognized feature only for XML Schemas. If the
+        // configuration doesn't support this feature, ignore it.
+        try {
+            fConfiguration.setFeature ( NORMALIZE_DATA, false );
+        }
+        catch (XMLConfigurationException exc) {}
+    
     } // <init>(XMLParserConfiguration)
 
     /**
@@ -247,6 +260,11 @@
      */
     public void reset () {
         super.reset ();
+        
+        // get state of namespace-declarations parameter.
+        fNamespaceDeclarations = 
+            fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS);
+                
         // DOM Filter
         if (fSkippedElemStack!=null) {
             fSkippedElemStack.removeAllElements ();
@@ -336,8 +354,10 @@
                 else if (name.equalsIgnoreCase (Constants.DOM_INFOSET)) {
                     // Setting false has no effect.
                     if (state) {
-                        // true: namespaces, comments, element-content-whitespace
+                        // true: namespaces, namespace-declarations, 
+                        // comments, element-content-whitespace
                         fConfiguration.setFeature(NAMESPACES, true);
+                        fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, true);
                         fConfiguration.setFeature(INCLUDE_COMMENTS_FEATURE, true);
                         fConfiguration.setFeature(INCLUDE_IGNORABLE_WHITESPACE, true);
 
@@ -352,8 +372,10 @@
                 else if (name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)) {
                     fConfiguration.setFeature(CREATE_CDATA_NODES_FEATURE, state);
                 }
-                else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)
-                || name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
+                else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)) {
+                    fConfiguration.setFeature(Constants.DOM_NAMESPACE_DECLARATIONS, state);
+                }
+                else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
                 || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
                     if (!state) { // false is not supported
                         String msg =
@@ -616,6 +638,7 @@
             // to the configuration and is changing the values
             // of these features directly on it.
             boolean infoset = fConfiguration.getFeature(NAMESPACES) &&
+                fConfiguration.getFeature(Constants.DOM_NAMESPACE_DECLARATIONS) &&
                 fConfiguration.getFeature(INCLUDE_COMMENTS_FEATURE) &&
                 fConfiguration.getFeature(INCLUDE_IGNORABLE_WHITESPACE) &&
                 !fConfiguration.getFeature(DYNAMIC_VALIDATION) &&
@@ -695,8 +718,7 @@
                 // true is not supported
                 return (state) ? false : true;
             }
-            else if (name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)
-            || name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
+            else if (name.equalsIgnoreCase (Constants.DOM_WELLFORMED)
             || name.equalsIgnoreCase (Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
                 // false is not supported
                 return (state) ? true : false;
@@ -709,6 +731,7 @@
             || name.equalsIgnoreCase (Constants.DOM_ENTITIES)
             || name.equalsIgnoreCase (Constants.DOM_INFOSET)
             || name.equalsIgnoreCase (Constants.DOM_NAMESPACES)
+            || name.equalsIgnoreCase (Constants.DOM_NAMESPACE_DECLARATIONS)
             || name.equalsIgnoreCase (Constants.DOM_VALIDATE)
             || name.equalsIgnoreCase (Constants.DOM_VALIDATE_IF_SCHEMA)
             || name.equalsIgnoreCase (Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
@@ -991,4 +1014,30 @@
         return; // If not busy then this is noop
     }
 
+    /**
+     * The start of an element. If the document specifies the start element
+     * by using an empty tag, then the startElement method will immediately
+     * be followed by the endElement method, with no intervening methods.
+     * Overriding the parent to handle DOM_NAMESPACE_DECLARATIONS=false.
+     *
+     * @param element    The name of the element.
+     * @param attributes The element attributes.
+     * @param augs     Additional information that may include infoset augmentations
+     *
+     * @throws XNIException Thrown by handler to signal an error.
+     */
+    public void startElement (QName element, XMLAttributes attributes, Augmentations augs) {
+        // namespace declarations parameter has no effect if namespaces is false.
+        if (!fNamespaceDeclarations && fNamespaceAware) {
+            int len = attributes.getLength();
+            for (int i = len - 1; i >= 0; --i) {
+                if (XMLSymbols.PREFIX_XMLNS == attributes.getPrefix(i) ||
+                    XMLSymbols.PREFIX_XMLNS == attributes.getQName(i)) {
+                    attributes.removeAttributeAt(i);
+                }
+            }
+        }
+        super.startElement(element, attributes, augs);
+    }
+	
 } // class DOMParserImpl
Index: org/apache/xml/serialize/DOMSerializerImpl.java
===================================================================
retrieving revision 1.21
diff -u -r1.21 DOMSerializerImpl.java
--- org/apache/xml/serialize/DOMSerializerImpl.java	22 Apr 2004 20:39:04 -0000	1.21
+++ org/apache/xml/serialize/DOMSerializerImpl.java	7 May 2004 15:19:29 -0000
@@ -156,11 +156,12 @@
             boolean state = ((Boolean) value).booleanValue();
             if (name.equalsIgnoreCase(Constants.DOM_INFOSET)){
                 if (state){
-                    features &=~ENTITIES;
-                    features &=~CDATA;
-                    features |=NAMESPACES;
-                    features |=WELLFORMED;
-                    features |=COMMENTS;                 
+                    features &= ~ENTITIES;
+                    features &= ~CDATA;
+                    features |= NAMESPACES;
+                    features |= NSDECL;
+                    features |= WELLFORMED;
+                    features |= COMMENTS;                 
                 }
                 // false does not have any effect
             } else if (name.equalsIgnoreCase(Constants.DOM_XMLDECL)) {
@@ -221,9 +222,15 @@
                             new Object[] { name });
                     throw new DOMException(DOMException.NOT_SUPPORTED_ERR, msg);
                 }
-            } else if (
-                name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
-                    || name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
+            }else if (
+			name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+				//namespace-declaration has effect only if namespaces is true
+				features =
+					(short) (state
+						? features | NSDECL
+						: features & ~NSDECL);
+				serializer.fNamespacePrefixes = state;							
+            } else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
                     || name.equalsIgnoreCase(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
                 // false is not supported
                 if (!state) {
@@ -289,7 +296,8 @@
             || name.equalsIgnoreCase(Constants.DOM_INFOSET)
             || name.equalsIgnoreCase(Constants.DOM_ENTITIES)
             || name.equalsIgnoreCase(Constants.DOM_CDATA_SECTIONS)
-            || name.equalsIgnoreCase(Constants.DOM_COMMENTS)){
+            || name.equalsIgnoreCase(Constants.DOM_COMMENTS)
+            || name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)){
 	            // both values supported
 				return true;
 			}
@@ -303,8 +311,7 @@
 				// true is not supported
 				return !value;
 			}
-			else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)
-			        || name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
+			else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE)
 			        || name.equalsIgnoreCase(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
 				// false is not supported
 				return value;
@@ -383,18 +390,20 @@
             return (features & SPLITCDATA) != 0 ? Boolean.TRUE : Boolean.FALSE;
         } else if (name.equalsIgnoreCase(Constants.DOM_WELLFORMED)) {
             return (features & WELLFORMED) != 0 ? Boolean.TRUE : Boolean.FALSE;
+        } else if (name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+            return (features & NSDECL) != 0 ? Boolean.TRUE : Boolean.FALSE;            
         } else if (name.equalsIgnoreCase(Constants.DOM_ELEMENT_CONTENT_WHITESPACE) ||
-                   name.equalsIgnoreCase(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)
-                    || name.equalsIgnoreCase(Constants.DOM_NAMESPACE_DECLARATIONS)) {
+                   name.equalsIgnoreCase(Constants.DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS)) {
             return Boolean.TRUE;
         }else if (name.equalsIgnoreCase(Constants.DOM_DISCARD_DEFAULT_CONTENT)){
             return ((features & DISCARDDEFAULT)!=0)?Boolean.TRUE:Boolean.FALSE;
         }else if (name.equalsIgnoreCase(Constants.DOM_INFOSET)){
             if ((features & ENTITIES) == 0 &&
-                 (features & CDATA) ==0 &&
-                 (features & NAMESPACES) !=0 &&
-                 (features & WELLFORMED) !=0 &&
-                 (features & COMMENTS) !=0){
+                 (features & CDATA) == 0 &&
+                 (features & NAMESPACES) != 0 &&
+                 (features & NSDECL) != 0 &&
+                 (features & WELLFORMED) != 0 &&
+                 (features & COMMENTS) != 0) {
                      return Boolean.TRUE;
                  }                 
                  return Boolean.FALSE;
@@ -954,7 +963,8 @@
         ser.reset();
         ser.features = features;
         ser.fDOMErrorHandler = fErrorHandler;
-        ser.fNamespaces = (features & NAMESPACES) !=0;
+        ser.fNamespaces = (features & NAMESPACES) != 0;
+        ser.fNamespacePrefixes = (features & NSDECL) != 0;
         ser._format.setOmitComments((features & COMMENTS)==0);
         ser._format.setOmitXMLDeclaration((features & XMLDECL) == 0);   
  
Index: org/apache/xml/serialize/XMLSerializer.java
===================================================================
retrieving revision 1.60
diff -u -r1.60 XMLSerializer.java
--- org/apache/xml/serialize/XMLSerializer.java	13 Apr 2004 17:30:01 -0000	1.60
+++ org/apache/xml/serialize/XMLSerializer.java	7 May 2004 15:19:29 -0000
@@ -124,6 +124,11 @@
      */
     protected boolean fNamespaces = false;
 
+    /**
+     * Controls whether namespace prefixes will be printed out during serialization
+     */
+    protected boolean fNamespacePrefixes = true;
+	
 
     private boolean fPreserveSpace;
 
@@ -841,7 +846,9 @@
                     // the prefix is either undeclared 
                     // or
                     // conflict: the prefix is bound to another URI
-                    printNamespaceAttr(prefix, uri);
+                    if (fNamespacePrefixes) {
+                        printNamespaceAttr(prefix, uri);
+                    }
                     fLocalNSBinder.declarePrefix(prefix, uri);
                     fNSBinder.declarePrefix(prefix, uri);
                 }
@@ -868,7 +875,9 @@
                     if (uri !=null && uri.length() > 0) {
                         // there is a default namespace decl that is bound to
                         // non-zero length uri, output xmlns=""
-                        printNamespaceAttr(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
+                        if (fNamespacePrefixes) {
+                            printNamespaceAttr(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
+                        }
                         fLocalNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
                         fNSBinder.declarePrefix(XMLSymbols.EMPTY_STRING, XMLSymbols.EMPTY_STRING);
                     }
@@ -918,7 +927,7 @@
                         // check if we need to output this declaration
                         prefix = attr.getPrefix();
                         prefix = (prefix == null || 
-                                  prefix.length() == 0) ? XMLSymbols.EMPTY_STRING :fSymbolTable.addSymbol(prefix);
+                                  prefix.length() == 0) ? XMLSymbols.EMPTY_STRING : fSymbolTable.addSymbol(prefix);
                         localpart = fSymbolTable.addSymbol( attr.getLocalName());
                         if (prefix == XMLSymbols.PREFIX_XMLNS) { //xmlns:prefix
                             localUri = fLocalNSBinder.getURI(localpart);  // local prefix mapping
@@ -926,7 +935,13 @@
                             if (value.length() != 0 ) {
                                 if (localUri == null) {
                                     // declaration was not printed while fixing element namespace binding
-                                    printNamespaceAttr(localpart, value);
+                                    
+                                    // If the DOM Level 3 namespace-prefixes feature is set to false
+                                    // do not print xmlns attributes
+                                    if (fNamespacePrefixes) {
+                                        printNamespaceAttr(localpart, value);
+                                    }
+                                    	
                                     // case 4: <elem xmlns:xx="foo" xx:attr=""/>
                                     // where attribute is bound to "bar". 
                                     // If the xmlns:xx is output here first, later we should not
@@ -948,7 +963,9 @@
                             value = fSymbolTable.addSymbol(value);
                             if (localUri == null ){
                                 // declaration was not printed while fixing element namespace binding
-                                printNamespaceAttr(XMLSymbols.EMPTY_STRING, value);
+                                if (fNamespacePrefixes) {
+                                    printNamespaceAttr(XMLSymbols.EMPTY_STRING, value);
+                                }
                                 // case 4 does not apply here since attributes can't use
                                 // default namespace
                             }
@@ -997,7 +1014,9 @@
                                 name=prefix+":"+localpart;
                             }
                             // add declaration for the new prefix
-                            printNamespaceAttr(prefix, uri);
+                            if (fNamespacePrefixes) {
+                                printNamespaceAttr(prefix, uri);
+                            }
                             value = fSymbolTable.addSymbol(value);
                             fLocalNSBinder.declarePrefix(prefix, value);
                             fNSBinder.declarePrefix(prefix, uri);
