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 2011/03/25 19:50:09 UTC

svn commit: r1085513 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java

Author: mrglavas
Date: Fri Mar 25 18:50:09 2011
New Revision: 1085513

URL: http://svn.apache.org/viewvc?rev=1085513&view=rev
Log:
Fixing JIRA Issue #1501: http://issues.apache.org/jira/browse/XERCESJ-1501. Namespace declarations may have been added by namespace fix-up. If the "namespace-declarations" parameter has been set to false we need to fetch the AttributeMap again if it contained no attributes prior to namespace fix-up.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java?rev=1085513&r1=1085512&r2=1085513&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/dom/DOMNormalizer.java Fri Mar 25 18:50:09 2011
@@ -345,13 +345,21 @@ public class DOMNormalizer implements XM
                     // 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;
+                    if ((fConfiguration.features & DOMConfigurationImpl.NSDECL) == 0) {
+                        // Namespace declarations may have been added by namespace fix-up. Need
+                        // to fetch the AttributeMap again if it contained no attributes prior
+                        // to namespace fix-up.
+                        if (attributes == null) {
+                            attributes = (elem.hasAttributes()) ? (AttributeMap) elem.getAttributes() : null;
+                        }
+                        if (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;
+                                }
                             }
                         }
                     }  



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