You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2012/09/05 10:19:36 UTC
svn commit: r1381057 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-api/src/main/java/org/apache/axiom/om/
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
Author: veithen
Date: Wed Sep 5 08:19:35 2012
New Revision: 1381057
URL: http://svn.apache.org/viewvc?rev=1381057&view=rev
Log:
Use a single set of constants (namely the ones already defined by the JRE) for "http://www.w3.org/2000/xmlns/" and "xmlns". They are only relevant for DOM, so we don't need to define our own constants.
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java
webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/OMConstants.java Wed Sep 5 08:19:35 2012
@@ -19,6 +19,8 @@
package org.apache.axiom.om;
+import javax.xml.XMLConstants;
+
/** Interface OMConstants */
public interface OMConstants {
@@ -60,7 +62,14 @@ public interface OMConstants {
String XMLNS_URI =
"http://www.w3.org/XML/1998/namespace";
+ /**
+ * @deprecated Use {@link XMLConstants#XMLNS_ATTRIBUTE_NS_URI} instead.
+ */
String XMLNS_NS_URI = "http://www.w3.org/2000/xmlns/";
+
+ /**
+ * @deprecated Use {@link XMLConstants#XMLNS_ATTRIBUTE} instead.
+ */
String XMLNS_NS_PREFIX = "xmlns";
String XMLNS_PREFIX =
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/AttrImpl.java Wed Sep 5 08:19:35 2012
@@ -34,6 +34,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.Text;
import org.w3c.dom.TypeInfo;
+import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -108,9 +109,9 @@ public class AttrImpl extends RootNode i
this(ownerDocument, factory);
this.localName = name;
//If this is a default namespace attr
- if (OMConstants.XMLNS_NS_PREFIX.equals(name)) {
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(name)) {
this.namespace = new OMNamespaceImpl(
- OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX);
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE);
}
this.type = OMConstants.XMLATTRTYPE_CDATA;
}
@@ -139,7 +140,7 @@ public class AttrImpl extends RootNode i
public String getNodeName() {
return (this.namespace != null
&& !"".equals(this.namespace.getPrefix()) &&
- !(OMConstants.XMLNS_NS_PREFIX.equals(this.localName)))
+ !(XMLConstants.XMLNS_ATTRIBUTE.equals(this.localName)))
? this.namespace.getPrefix() + ":" + this.localName
: this.localName;
}
@@ -207,10 +208,10 @@ public class AttrImpl extends RootNode i
// /
public String getName() {
if (this.namespace != null) {
- if ((OMConstants.XMLNS_NS_PREFIX.equals(this.localName))) {
+ if ((XMLConstants.XMLNS_ATTRIBUTE.equals(this.localName))) {
return this.localName;
- } else if (OMConstants.XMLNS_NS_URI.equals(this.namespace.getNamespaceURI())) {
- return OMConstants.XMLNS_NS_PREFIX + ":" + this.localName;
+ } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(this.namespace.getNamespaceURI())) {
+ return XMLConstants.XMLNS_ATTRIBUTE + ":" + this.localName;
} else if (this.namespace.getPrefix().equals("")) {
return this.localName;
} else {
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/DocumentImpl.java Wed Sep 5 08:19:35 2012
@@ -20,7 +20,6 @@
package org.apache.axiom.om.impl.dom;
import org.apache.axiom.om.OMCloneOptions;
-import org.apache.axiom.om.OMConstants;
import org.apache.axiom.om.OMDocument;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
@@ -52,6 +51,7 @@ import org.w3c.dom.NodeList;
import org.w3c.dom.ProcessingInstruction;
import org.w3c.dom.Text;
+import javax.xml.XMLConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import java.io.OutputStream;
@@ -135,7 +135,7 @@ public class DocumentImpl extends RootNo
String localName = DOMUtil.getLocalName(qualifiedName);
String prefix = DOMUtil.getPrefix(qualifiedName);
- if (!OMConstants.XMLNS_NS_PREFIX.equals(localName)) {
+ if (!XMLConstants.XMLNS_ATTRIBUTE.equals(localName)) {
this.checkQName(prefix, localName);
} else {
return this.createAttribute(localName);
@@ -288,7 +288,7 @@ public class DocumentImpl extends RootNo
Attr attr = (Attr) sourceAttrs.item(index);
if (attr.getNamespaceURI() != null
&& !attr.getNamespaceURI().equals(
- OMConstants.XMLNS_NS_URI)) {
+ XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
Attr newAttr = (Attr) importNode(attr, true);
newElement.setAttributeNodeNS(newAttr);
} else { // if (attr.getLocalName() == null) {
@@ -308,7 +308,7 @@ public class DocumentImpl extends RootNo
newNode = createAttribute(importedNode.getNodeName());
} else {
//Check whether it is a default ns decl
- if (OMConstants.XMLNS_NS_PREFIX.equals(importedNode.getNodeName())) {
+ if (XMLConstants.XMLNS_ATTRIBUTE.equals(importedNode.getNodeName())) {
newNode = createAttribute(importedNode.getNodeName());
} else {
String ns = importedNode.getNamespaceURI();
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/ElementImpl.java Wed Sep 5 08:19:35 2012
@@ -50,6 +50,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.TypeInfo;
+import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
@@ -364,14 +365,14 @@ public class ElementImpl extends ParentN
// check whether the attr is in use
attrImpl.checkInUse();
- if (attr.getNodeName().startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
+ if (attr.getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) {
// This is a ns declaration
this.declareNamespace(attr.getNodeValue(), DOMUtil
.getLocalName(attr.getName()));
//Don't add this to attr list, since its a namespace
return attr;
- } else if (attr.getNodeName().equals(OMConstants.XMLNS_NS_PREFIX)) {
+ } else if (attr.getNodeName().equals(XMLConstants.XMLNS_ATTRIBUTE)) {
this.declareDefaultNamespace(attr.getValue());
//Don't add this to attr list, since its a namespace
@@ -398,10 +399,10 @@ public class ElementImpl extends ParentN
null);
throw new DOMException(DOMException.INVALID_CHARACTER_ERR, msg);
}
- if (name.startsWith(OMConstants.XMLNS_NS_PREFIX + ":")) {
+ if (name.startsWith(XMLConstants.XMLNS_ATTRIBUTE + ":")) {
// This is a ns declaration
this.declareNamespace(value, DOMUtil.getLocalName(name));
- } else if (name.equals(OMConstants.XMLNS_NS_PREFIX)) {
+ } else if (name.equals(XMLConstants.XMLNS_ATTRIBUTE)) {
this.declareDefaultNamespace(value);
} else {
this.setAttributeNode(new AttrImpl(ownerDocument(), name, value,
@@ -610,7 +611,7 @@ public class ElementImpl extends ParentN
}
public OMNamespace addNamespaceDeclaration(String uri, String prefix) {
- setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, uri);
+ setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, uri);
return new OMNamespaceImpl(uri, prefix);
}
@@ -630,15 +631,15 @@ public class ElementImpl extends ParentN
throw new IllegalArgumentException("Cannot bind a prefix to the empty namespace name");
}
- if (!namespace.getPrefix().startsWith(OMConstants.XMLNS_NS_PREFIX)) {
- setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, namespace.getNamespaceURI());
+ if (!namespace.getPrefix().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
+ setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, namespace.getNamespaceURI());
}
}
return namespace;
}
public void undeclarePrefix(String prefix) {
- setAttributeNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : OMConstants.XMLNS_NS_PREFIX + ":" + prefix, "");
+ setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : XMLConstants.XMLNS_ATTRIBUTE + ":" + prefix, "");
}
public OMNamespace declareNamespace(String uri, String prefix) {
@@ -658,12 +659,12 @@ public class ElementImpl extends ParentN
"the namespace information of the element");
}
- setAttributeNS(OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX, uri);
+ setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE, uri);
return new OMNamespaceImpl(uri, "");
}
public OMNamespace getDefaultNamespace() {
- Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, OMConstants.XMLNS_NS_PREFIX);
+ Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, XMLConstants.XMLNS_ATTRIBUTE);
if (decl != null) {
String uri = decl.getValue();
return uri.length() == 0 ? null : new OMNamespaceImpl(uri, "");
@@ -713,7 +714,7 @@ public class ElementImpl extends ParentN
public OMNamespace findNamespaceURI(String prefix) {
if (attributes != null) {
- Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : prefix);
+ Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : prefix);
if (decl != null) {
String namespaceURI = decl.getValue();
if (prefix != null && prefix.length() > 0 && namespaceURI.length() == 0) {
@@ -740,8 +741,8 @@ public class ElementImpl extends ParentN
private OMNamespace findDeclaredNamespace(String uri, String prefix) {
if (uri == null) {
- Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI,
- prefix.length() == 0 ? OMConstants.XMLNS_NS_PREFIX : prefix);
+ Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI,
+ prefix.length() == 0 ? XMLConstants.XMLNS_ATTRIBUTE : prefix);
return decl == null ? null : new OMNamespaceImpl(decl.getValue(), prefix);
}
// If the prefix is available and uri is available and its the xml
@@ -754,7 +755,7 @@ public class ElementImpl extends ParentN
if (prefix == null || "".equals(prefix)) {
for (int i=0; i<attributes.getLength(); i++) {
Attr attr = (Attr)attributes.item(i);
- if (OMConstants.XMLNS_NS_URI.equals(attr.getNamespaceURI())) {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI())) {
String declaredUri = attr.getValue();
if (declaredUri.equals(uri)) {
return new OMNamespaceImpl(uri, attr.getPrefix() == null ? "" : attr.getLocalName());
@@ -762,7 +763,7 @@ public class ElementImpl extends ParentN
}
}
} else {
- Attr decl = (Attr)attributes.getNamedItemNS(OMConstants.XMLNS_NS_URI, prefix);
+ Attr decl = (Attr)attributes.getNamedItemNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, prefix);
if (decl != null) {
String declaredUri = decl.getValue();
if (declaredUri.equals(uri)) {
@@ -993,7 +994,7 @@ public class ElementImpl extends ParentN
for (int i = 0; i < attributes.getLength(); i++) {
OMAttribute item = (OMAttribute) attributes.getItem(i);
if (item.getNamespace() == null
- || !(item.getNamespace() != null && OMConstants.XMLNS_NS_URI
+ || !(item.getNamespace() != null && XMLConstants.XMLNS_ATTRIBUTE_NS_URI
.equals(item.getNamespace().getNamespaceURI()))) {
list.add(item);
}
@@ -1057,7 +1058,7 @@ public class ElementImpl extends ParentN
AttrImpl attr = (AttrImpl)attributes.item(i);
AttrImpl clonedAttr = (AttrImpl)attr.clone(options, null, true, false);
clonedAttr.isSpecified(attr.isSpecified());
- clone.setAttributeNodeNS(clonedAttr, false, namespaceRepairing && !OMConstants.XMLNS_NS_URI.equals(attr.getNamespaceURI()));
+ clone.setAttributeNodeNS(clonedAttr, false, namespaceRepairing && !XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI()));
}
return clone;
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NSDeclIterator.java Wed Sep 5 08:19:35 2012
@@ -20,7 +20,8 @@ package org.apache.axiom.om.impl.dom;
import java.util.Iterator;
-import org.apache.axiom.om.OMConstants;
+import javax.xml.XMLConstants;
+
import org.apache.axiom.om.impl.common.OMNamespaceImpl;
import org.w3c.dom.Attr;
@@ -44,7 +45,7 @@ class NSDeclIterator implements Iterator
break;
}
Attr attr = (Attr)attributes.item(index);
- if (OMConstants.XMLNS_NS_URI.equals(attr.getNamespaceURI())) {
+ if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attr.getNamespaceURI())) {
nsDecl = attr;
hasNextCalled = true;
break;
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java?rev=1381057&r1=1381056&r2=1381057&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/NodeImpl.java Wed Sep 5 08:19:35 2012
@@ -44,6 +44,7 @@ import java.io.OutputStream;
import java.io.Writer;
import java.util.Hashtable;
+import javax.xml.XMLConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -278,10 +279,10 @@ public abstract class NodeImpl implement
String attrPrefix = attr.getPrefix();
String value = attr.getNodeValue();
namespace = attr.getNamespaceURI();
- if (namespace != null && namespace.equals("http://www.w3.org/2000/xmlns/")) {
- if (specifiedPrefix == null && attr.getNodeName().equals("xmlns")) {
+ if (namespace != null && namespace.equals(XMLConstants.XMLNS_ATTRIBUTE_NS_URI)) {
+ if (specifiedPrefix == null && attr.getNodeName().equals(XMLConstants.XMLNS_ATTRIBUTE)) {
return value.length() > 0 ? value : null;
- } else if (attrPrefix != null && attrPrefix.equals("xmlns")
+ } else if (attrPrefix != null && attrPrefix.equals(XMLConstants.XMLNS_ATTRIBUTE)
&& attr.getLocalName().equals(specifiedPrefix)) {
return value.length() > 0 ? value : null;
}