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 2009/04/17 14:42:47 UTC
svn commit: r765972 - in /xerces/java/trunk/src/org/apache/xerces:
dom/DeferredElementNSImpl.java parsers/AbstractDOMParser.java
Author: mrglavas
Date: Fri Apr 17 12:42:47 2009
New Revision: 765972
URL: http://svn.apache.org/viewvc?rev=765972&view=rev
Log:
Fixing bugs in the processing of defaulted attributes during DOM construction.
We need to take special care of how we process 'xmlns' and need to ensure that
all 'xmlns', 'xmlns:*' and 'xml:*' attributes have a namespace when the parser
is namespace-aware.
Modified:
xerces/java/trunk/src/org/apache/xerces/dom/DeferredElementNSImpl.java
xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java
Modified: xerces/java/trunk/src/org/apache/xerces/dom/DeferredElementNSImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/dom/DeferredElementNSImpl.java?rev=765972&r1=765971&r2=765972&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/dom/DeferredElementNSImpl.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/dom/DeferredElementNSImpl.java Fri Apr 17 12:42:47 2009
@@ -26,6 +26,7 @@
package org.apache.xerces.dom;
+import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xs.XSTypeDefinition;
import org.w3c.dom.NamedNodeMap;
@@ -124,7 +125,8 @@
// non-namespace aware setAttributeNode() method could overwrite
// another attribute with the same local name.
if (!attr.getSpecified() && (seenSchemaDefault ||
- (attr.getNamespaceURI() != null &&
+ (attr.getNamespaceURI() != null &&
+ attr.getNamespaceURI() != NamespaceContext.XMLNS_URI &&
attr.getName().indexOf(':') < 0))) {
seenSchemaDefault = true;
attrs.setNamedItemNS(attr);
Modified: xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java
URL: http://svn.apache.org/viewvc/xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java?rev=765972&r1=765971&r2=765972&view=diff
==============================================================================
--- xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java (original)
+++ xerces/java/trunk/src/org/apache/xerces/parsers/AbstractDOMParser.java Fri Apr 17 12:42:47 2009
@@ -951,7 +951,8 @@
// Take special care of schema defaulted attributes. Calling the
// non-namespace aware setAttributeNode() method could overwrite
// another attribute with the same local name.
- if (!specified && (seenSchemaDefault || (fAttrQName.uri != null && fAttrQName.prefix == null))) {
+ if (!specified && (seenSchemaDefault || (fAttrQName.uri != null &&
+ fAttrQName.uri != NamespaceContext.XMLNS_URI && fAttrQName.prefix == null))) {
el.setAttributeNodeNS(attr);
seenSchemaDefault = true;
}
@@ -2424,8 +2425,23 @@
fDeferredDocumentImpl.appendChild (fDocumentTypeIndex, elementDefIndex);
}
// add default attribute
+ boolean nsEnabled = fNamespaceAware;
+ String namespaceURI = null;
+ if (nsEnabled) {
+ // DOM Level 2 wants all namespace declaration attributes
+ // to be bound to "http://www.w3.org/2000/xmlns/"
+ // So as long as the XML parser doesn't do it, it needs to
+ // done here.
+ if (attributeName.startsWith("xmlns:") ||
+ attributeName.equals("xmlns")) {
+ namespaceURI = NamespaceContext.XMLNS_URI;
+ }
+ else if (attributeName.startsWith("xml:")) {
+ namespaceURI = NamespaceContext.XML_URI;
+ }
+ }
int attrIndex = fDeferredDocumentImpl.createDeferredAttribute (
- attributeName, defaultValue.toString (), false);
+ attributeName, namespaceURI, defaultValue.toString(), false);
if ("ID".equals (type)) {
fDeferredDocumentImpl.setIdAttribute (attrIndex);
}
@@ -2460,10 +2476,13 @@
// to be bound to "http://www.w3.org/2000/xmlns/"
// So as long as the XML parser doesn't do it, it needs to
// done here.
- if (attributeName.startsWith ("xmlns:") ||
- attributeName.equals ("xmlns")) {
+ if (attributeName.startsWith("xmlns:") ||
+ attributeName.equals("xmlns")) {
namespaceURI = NamespaceContext.XMLNS_URI;
}
+ else if (attributeName.startsWith("xml:")) {
+ namespaceURI = NamespaceContext.XML_URI;
+ }
attr = (AttrImpl)fDocumentImpl.createAttributeNS (namespaceURI,
attributeName);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org