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/01/28 02:00:10 UTC
cvs commit: xml-crimson/src/org/apache/crimson/util XmlNames.java
edwingo 01/01/27 17:00:10
Modified: src/org/apache/crimson/tree AttributeNode.java
AttributeSet.java ElementNode.java
NamespacedNode.java
src/org/apache/crimson/util XmlNames.java
Log:
Fix Node.setPrefix() doesn't throw an exception on bad argument, and clean up
Revision Changes Path
1.7 +5 -9 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.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AttributeNode.java 2001/01/28 00:44:19 1.6
+++ AttributeNode.java 2001/01/28 01:00:06 1.7
@@ -1,5 +1,5 @@
/*
- * $Id: AttributeNode.java,v 1.6 2001/01/28 00:44:19 edwingo Exp $
+ * $Id: AttributeNode.java,v 1.7 2001/01/28 01:00:06 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -100,7 +100,7 @@
*
* @author David Brownell
* @author Rajiv Mordani
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*/
final // at least for the moment
// public
@@ -114,11 +114,6 @@
attribute is set on an ElementNode */
private Element ownerElement;
- private static final String
- SPEC_XML_URI = "http://www.w3.org/XML/1998/namespace";
- static final String
- SPEC_XMLNS_URI = "http://www.w3.org/2000/xmlns/";
-
/** Constructs an attribute node. */
public AttributeNode(String name, String value,
boolean specified, String defaultValue)
@@ -167,7 +162,7 @@
throw new DomEx(DomEx.INVALID_CHARACTER_ERR);
}
if ("xmlns".equals(qualifiedName) &&
- !namespaceURI.equals(SPEC_XMLNS_URI)) {
+ !XmlNames.SPEC_XMLNS_URI.equals(namespaceURI)) {
throw new DomEx(DomEx.NAMESPACE_ERR);
}
return;
@@ -189,7 +184,8 @@
// If we get here then we must have a valid prefix
if (namespaceURI == null
- || ("xml".equals(prefix) && !namespaceURI.equals(SPEC_XML_URI))) {
+ || ("xml".equals(prefix)
+ && !XmlNames.SPEC_XML_URI.equals(namespaceURI))) {
throw new DomEx(DomEx.NAMESPACE_ERR);
}
}
1.8 +3 -3 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.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AttributeSet.java 2001/01/27 00:08:38 1.7
+++ AttributeSet.java 2001/01/28 01:00:06 1.8
@@ -1,5 +1,5 @@
/*
- * $Id: AttributeSet.java,v 1.7 2001/01/27 00:08:38 edwingo Exp $
+ * $Id: AttributeSet.java,v 1.8 2001/01/28 01:00:06 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.7 $
+ * @version $Revision: 1.8 $
*/
final
class AttributeSet implements NamedNodeMap, XmlWritable
@@ -140,7 +140,7 @@
if ("xmlns".equals(qName)
|| "xmlns".equals(XmlNames.getPrefix(qName))) {
// Associate the right namespaceURI with "xmlns" attributes
- uri = AttributeNode.SPEC_XMLNS_URI;
+ uri = XmlNames.SPEC_XMLNS_URI;
} else {
uri = source.getURI(i);
// Translate "" of SAX2 to null. See DOM2 spec under Node
1.5 +3 -5 xml-crimson/src/org/apache/crimson/tree/ElementNode.java
Index: ElementNode.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/ElementNode.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ElementNode.java 2001/01/27 00:22:19 1.4
+++ ElementNode.java 2001/01/28 01:00:07 1.5
@@ -1,5 +1,5 @@
/*
- * $Id: ElementNode.java,v 1.4 2001/01/27 00:22:19 edwingo Exp $
+ * $Id: ElementNode.java,v 1.5 2001/01/28 01:00:07 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -98,7 +98,7 @@
* @see XmlDocumentBuilder
*
* @author David Brownell
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class ElementNode extends NamespacedNode implements ElementEx
{
@@ -108,8 +108,6 @@
private static final char tagStart [] = { '<', '/' };
private static final char tagEnd [] = { ' ', '/', '>' };
- private static final String
- SPEC_XML_URI = "http://www.w3.org/XML/1998/namespace";
/**
* Partially constructs an element; its tag will be assigned by the
@@ -179,7 +177,7 @@
// If we get here then we must have a valid prefix
if (namespaceURI == null || namespaceURI.equals("")
|| (prefix.equals("xml") &&
- !namespaceURI.equals(SPEC_XML_URI))) {
+ !XmlNames.SPEC_XML_URI.equals(namespaceURI))) {
throw new DomEx(DomEx.NAMESPACE_ERR);
}
}
1.2 +22 -2 xml-crimson/src/org/apache/crimson/tree/NamespacedNode.java
Index: NamespacedNode.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/tree/NamespacedNode.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- NamespacedNode.java 2000/11/23 01:53:35 1.1
+++ NamespacedNode.java 2001/01/28 01:00:07 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: NamespacedNode.java,v 1.1 2000/11/23 01:53:35 edwingo Exp $
+ * $Id: NamespacedNode.java,v 1.2 2001/01/28 01:00:07 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -67,7 +67,7 @@
* for more info.
*
* @author Edwin Goei
- * @version $Revision: 1.1 $
+ * @version $Revision: 1.2 $
*/
abstract class NamespacedNode extends ParentNode {
/**
@@ -117,6 +117,26 @@
}
return;
}
+
+ // Check for illegal characters
+ if (!XmlNames.isUnqualifiedName(prefix)) {
+ throw new DomEx(DomEx.INVALID_CHARACTER_ERR);
+ }
+
+ // Check for NAMESPACE_ERR part 1
+ if (namespaceURI == null
+ || "xml".equals(prefix)
+ && !XmlNames.SPEC_XML_URI.equals(namespaceURI)) {
+ throw new DomEx(DomEx.NAMESPACE_ERR);
+ }
+ // Check for NAMESPACE_ERR part 2
+ if (getNodeType() == ATTRIBUTE_NODE) {
+ if ("xmlns".equals(prefix)
+ && !XmlNames.SPEC_XMLNS_URI.equals(namespaceURI)
+ || "xmlns".equals(name)) {
+ throw new DomEx(DomEx.NAMESPACE_ERR);
+ }
+ }
// Replace or add new prefix
StringBuffer tmp = new StringBuffer(prefix);
1.2 +9 -1 xml-crimson/src/org/apache/crimson/util/XmlNames.java
Index: XmlNames.java
===================================================================
RCS file: /home/cvs/xml-crimson/src/org/apache/crimson/util/XmlNames.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XmlNames.java 2000/11/23 01:53:35 1.1
+++ XmlNames.java 2001/01/28 01:00:09 1.2
@@ -1,5 +1,5 @@
/*
- * $Id: XmlNames.java,v 1.1 2000/11/23 01:53:35 edwingo Exp $
+ * $Id: XmlNames.java,v 1.2 2001/01/28 01:00:09 edwingo Exp $
*
* The Apache Software License, Version 1.1
*
@@ -68,6 +68,14 @@
*/
public class XmlNames
{
+ /**
+ * Useful strings from the DOM Level 2 Spec
+ */
+ public static final String
+ SPEC_XML_URI = "http://www.w3.org/XML/1998/namespace";
+ public static final String
+ SPEC_XMLNS_URI = "http://www.w3.org/2000/xmlns/";
+
private XmlNames () { }