elena 2002/08/01 10:41:34
Modified: java/src/org/apache/xerces/dom AttrNSImpl.java
ElementNSImpl.java
Log:
Allow value for setPrefix to be null or empty string:
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=8738
Revision Changes Path
1.29 +29 -17 xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java
Index: AttrNSImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/AttrNSImpl.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- AttrNSImpl.java 25 Jul 2002 19:16:11 -0000 1.28
+++ AttrNSImpl.java 1 Aug 2002 17:41:33 -0000 1.29
@@ -256,16 +256,19 @@
return index < 0 ? null : name.substring(0, index);
}
- /**
+ /**
* Introduced in DOM Level 2. <p>
- *
+ *
* Note that setting this attribute changes the nodeName attribute, which
* holds the qualified name, as well as the tagName and name attributes of
* the Element and Attr interfaces, when applicable.<p>
+ *
+ * @param prefix The namespace prefix of this node, or null(empty string) if it
is unspecified.
*
- * @throws INVALID_CHARACTER_ERR Raised if the specified
- * prefix contains an invalid character.
- *
+ * @exception INVALID_CHARACTER_ERR
+ * Raised if the specified
+ * prefix contains an invalid character.
+ * @exception DOMException
* @since WD-DOM-Level-2-19990923
*/
public void setPrefix(String prefix)
@@ -279,15 +282,18 @@
String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"NO_MODIFICATION_ALLOWED_ERR", null);
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
- if (!CoreDocumentImpl.isXMLName(prefix)) {
- String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_CHARACTER_ERR", null);
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
- }
- if (namespaceURI == null || prefix.indexOf(':') >=0) {
- String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
- } else if (prefix != null) {
- if (prefix.equals("xmlns")) {
+ if (prefix != null && prefix.length() != 0) {
+
+ if (!CoreDocumentImpl.isXMLName(prefix)) {
+ String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_CHARACTER_ERR", null);
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
+ }
+ if (namespaceURI == null || prefix.indexOf(':') >=0) {
+ String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+
+ }
+ if (prefix.equals("xmlns")) {
if (!namespaceURI.equals(xmlnsURI)){
String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
@@ -301,10 +307,16 @@
String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
throw new DOMException(DOMException.NAMESPACE_ERR, msg);
}
- }
+ }
}
+
// update node name with new qualifiedName
- name = prefix + ":" + localName;
+ if (prefix !=null && prefix.length() != 0) {
+ name = prefix + ":" + localName;
+ }
+ else {
+ name = localName;
+ }
}
/**
1.26 +28 -20 xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java
Index: ElementNSImpl.java
===================================================================
RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/dom/ElementNSImpl.java,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- ElementNSImpl.java 30 Jul 2002 22:09:29 -0000 1.25
+++ ElementNSImpl.java 1 Aug 2002 17:41:33 -0000 1.26
@@ -259,16 +259,19 @@
return index < 0 ? null : name.substring(0, index);
}
- /**
+ /**
* Introduced in DOM Level 2. <p>
- *
+ *
* Note that setting this attribute changes the nodeName attribute, which holds
the
* qualified name, as well as the tagName and name attributes of the Element
* and Attr interfaces, when applicable.<p>
+ *
+ * @param prefix The namespace prefix of this node, or null(empty string) if it
is unspecified.
*
- * @throws INVALID_CHARACTER_ERR Raised if the specified
- * prefix contains an invalid character.
- *
+ * @exception INVALID_CHARACTER_ERR
+ * Raised if the specified
+ * prefix contains an invalid character.
+ * @exception DOMException
* @since WD-DOM-Level-2-19990923
*/
public void setPrefix(String prefix)
@@ -284,24 +287,29 @@
DOMException.NO_MODIFICATION_ALLOWED_ERR,
msg);
}
- if (!CoreDocumentImpl.isXMLName(prefix)) {
- String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_CHARACTER_ERR", null);
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
- }
- if (namespaceURI == null || prefix.indexOf(':') >=0) {
- String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
- } else if (prefix != null) {
- if (prefix.equals("xml")) {
- if (!namespaceURI.equals(xmlURI)) {
- String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
- throw new DOMException(DOMException.NAMESPACE_ERR, msg);
- }
+ if (prefix != null && prefix.length() != 0) {
+ if (!CoreDocumentImpl.isXMLName(prefix)) {
+ String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"INVALID_CHARACTER_ERR", null);
+ throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
+ }
+ if (namespaceURI == null || prefix.indexOf(':') >=0) {
+ String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+ } else if (prefix.equals("xml")) {
+ if (!namespaceURI.equals(xmlURI)) {
+ String msg =
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NAMESPACE_ERR",
null);
+ throw new DOMException(DOMException.NAMESPACE_ERR, msg);
+ }
}
}
}
// update node name with new qualifiedName
- name = prefix + ":" + localName;
+ if (prefix !=null && prefix.length() != 0) {
+ name = prefix + ":" + localName;
+ }
+ else {
+ name = localName;
+ }
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]