You are viewing a plain text version of this content. The canonical link for it is here.
Posted to crimson-cvs@xml.apache.org by ed...@apache.org on 2001/03/16 22:55:04 UTC
cvs commit: xml-crimson/src/org/apache/crimson/tree DOMImplementationImpl.java AttributeSet.java AttributeNode.java
edwingo 01/03/16 13:55:03
Modified: src/org/apache/crimson/tree DOMImplementationImpl.java
AttributeSet.java AttributeNode.java
Log:
Fixed: NamedNodeMap.removeNamedItemNS() doesn't replace an attribute with
default value. DOMImplementation.createDocumentType() accepts
qualifiedName="?root"
Revision Changes Path
1.3 +9 -1 xml-crimson/src/org/apache/crimson/tree/DOMImplementationImpl.java
Index: DOMImplementationImpl.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/DOMImplementationImpl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DOMImplementationImpl.java 2001/01/24 03:55:56 1.2
+++ DOMImplementationImpl.java 2001/03/16 21:54:48 1.3
@@ -57,12 +57,13 @@
package org.apache.crimson.tree;
import org.w3c.dom.*;
+import org.apache.crimson.util.XmlNames;
/**
* This class implements the DOM <em>DOMImplementation</em> interface.
*
* @author Edwin Goei
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class DOMImplementationImpl implements DOMImplementation
{
@@ -108,6 +109,13 @@
String publicId,
String systemId)
{
+ if (!XmlNames.isName(qualifiedName)) {
+ throw new DomEx(DOMException.INVALID_CHARACTER_ERR);
+ }
+ if (!XmlNames.isQualifiedName(qualifiedName)) {
+ throw new DomEx(DOMException.NAMESPACE_ERR);
+ }
+
// Note that DOM2 specifies that ownerDocument = null
return new Doctype(qualifiedName, publicId, systemId,
/* internalSubset */ null);
1.12 +30 -20 xml-crimson/src/org/apache/crimson/tree/AttributeSet.java
Index: AttributeSet.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/AttributeSet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- AttributeSet.java 2001/03/16 03:47:14 1.11
+++ AttributeSet.java 2001/03/16 21:54:52 1.12
@@ -1,5 +1,5 @@
/*
- * $Id: AttributeSet.java,v 1.11 2001/03/16 03:47:14 edwingo Exp $
+ * $Id: AttributeSet.java,v 1.12 2001/03/16 21:54:52 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -80,7 +80,7 @@
* document or was instead defaulted by attribute processing.
*
* @author David Brownell
- * @version $Revision: 1.11 $
+ * @version $Revision: 1.12 $
*/
final
class AttributeSet implements NamedNodeMap, XmlWritable
@@ -303,10 +303,12 @@
for (int i = 0; i < list.size(); i++) {
Node value = item(i);
String iLocalName = value.getLocalName();
- if (iLocalName != null && iLocalName.equals(localName)) {
+ // assert(iLocalName != null);
+ if (iLocalName.equals(localName)) {
String iNamespaceURI = value.getNamespaceURI();
- if (iNamespaceURI != null
- && iNamespaceURI.equals(namespaceURI)) {
+ if (iNamespaceURI == namespaceURI ||
+ (iNamespaceURI != null
+ && iNamespaceURI.equals(namespaceURI))) {
return value;
}
}
@@ -335,17 +337,19 @@
for (int i = 0; i < list.size(); i++) {
Node value = (Node)list.elementAt(i);
if (value.getNodeName().equals(name)) {
- AttributeNode att = (AttributeNode)value;
+ // Found a match
+ list.removeElementAt(i);
- String defaultValue = att.getDefaultValue();
+ AttributeNode attr = (AttributeNode)value;
+ String defaultValue = attr.getDefaultValue();
if (defaultValue != null) {
// Replace with Attr node of default value
- att.setValue(defaultValue);
- att.setSpecified(false);
- } else {
- list.removeElementAt(i);
+ AttributeNode newAttr = attr.cloneAttributeNode(true);
+ newAttr.setOwnerElement(attr.getOwnerElement());
+ newAttr.setValue(defaultValue);
+ newAttr.setSpecified(false);
+ list.addElement(newAttr);
}
-
return value;
}
}
@@ -365,18 +369,24 @@
for (int i = 0; i < list.size(); i++) {
Node value = (Node)list.elementAt(i);
String iLocalName = value.getLocalName();
- if (iLocalName != null && iLocalName.equals(localName)) {
+ // assert(iLocalName != null);
+ if (iLocalName.equals(localName)) {
String iNamespaceURI = value.getNamespaceURI();
- if (iNamespaceURI != null
- && iNamespaceURI.equals(namespaceURI)) {
+ if (iNamespaceURI == namespaceURI ||
+ (iNamespaceURI != null
+ && iNamespaceURI.equals(namespaceURI))) {
+ // Found a match
+ list.removeElementAt(i);
+
AttributeNode attr = (AttributeNode)value;
String defaultValue = attr.getDefaultValue();
if (defaultValue != null) {
- // Replace with Attr node of default value
- attr.setValue(defaultValue);
- attr.setSpecified(false);
- } else {
- list.removeElementAt(i);
+ // Replace with new Attr node of default value
+ AttributeNode newAttr = attr.cloneAttributeNode(true);
+ newAttr.setOwnerElement(attr.getOwnerElement());
+ newAttr.setValue(defaultValue);
+ newAttr.setSpecified(false);
+ list.addElement(newAttr);
}
return value;
}
1.10 +3 -3 xml-crimson/src/org/apache/crimson/tree/AttributeNode.java
Index: AttributeNode.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/AttributeNode.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- AttributeNode.java 2001/02/28 00:19:51 1.9
+++ AttributeNode.java 2001/03/16 21:54:54 1.10
@@ -1,5 +1,5 @@
/*
- * $Id: AttributeNode.java,v 1.9 2001/02/28 00:19:51 edwingo Exp $
+ * $Id: AttributeNode.java,v 1.10 2001/03/16 21:54:54 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -100,7 +100,7 @@
*
* @author David Brownell
* @author Rajiv Mordani
- * @version $Revision: 1.9 $
+ * @version $Revision: 1.10 $
*/
public class AttributeNode extends NamespacedNode implements Attr
{
@@ -291,7 +291,7 @@
/**
* Clone this AttributeNode and possibly its children (which cannot be
- * AttributeNodes themselves).
+ * AttributeNodes themselves). "ownerElement" will remain null.
*/
AttributeNode cloneAttributeNode(boolean deep) {
try {
---------------------------------------------------------------------
To unsubscribe, e-mail: crimson-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: crimson-cvs-help@xml.apache.org