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 2011/07/21 14:58:22 UTC
svn commit: r1149153 - in /webservices/commons/trunk/modules/axiom/modules:
axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/
axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/
axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/
Author: veithen
Date: Thu Jul 21 12:58:19 2011
New Revision: 1149153
URL: http://svn.apache.org/viewvc?rev=1149153&view=rev
Log:
AXIOM-373: Synchronized some code between the LLOM and DOOM implementations in order to fix some issues with generated prefixes.
Modified:
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/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
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=1149153&r1=1149152&r2=1149153&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 Thu Jul 21 12:58:19 2011
@@ -97,8 +97,9 @@ public class ElementImpl extends ParentN
NamespaceImpl ns, OMFactory factory) {
super(ownerDocument, factory);
this.localName = tagName;
- this.namespace = ns;
- this.declareNamespace(ns);
+ if (ns != null) {
+ setNamespace(ns);
+ }
this.attributes = new AttributeMap(this);
this.done = true;
}
@@ -107,9 +108,10 @@ public class ElementImpl extends ParentN
NamespaceImpl ns, OMXMLParserWrapper builder, OMFactory factory) {
super(ownerDocument, factory);
this.localName = tagName;
- this.namespace = ns;
+ if (ns != null) {
+ setNamespace(ns);
+ }
this.builder = builder;
- this.declareNamespace(ns);
this.attributes = new AttributeMap(this);
}
@@ -135,11 +137,10 @@ public class ElementImpl extends ParentN
OMXMLParserWrapper builder, OMFactory factory) {
this(factory);
this.localName = tagName;
- this.namespace = ns;
- this.builder = builder;
if (ns != null) {
- this.declareNamespace(ns);
+ setNamespace(ns);
}
+ this.builder = builder;
this.attributes = new AttributeMap(this);
}
@@ -148,6 +149,19 @@ public class ElementImpl extends ParentN
this.ownerNode = ((OMDOMFactory) factory).getDocument();
}
+ private OMNamespace handleNamespace(OMNamespace ns) {
+ String namespaceURI = ns.getNamespaceURI();
+ String prefix = ns.getPrefix();
+ if (namespaceURI.length() == 0 && prefix != null && prefix.length() > 0) {
+ throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
+ }
+ OMNamespace namespace = findNamespace(namespaceURI, prefix);
+ if (namespace == null) {
+ namespace = declareNamespace(ns);
+ }
+ return namespace;
+ }
+
// /
// /org.w3c.dom.Node methods
// /
@@ -1017,12 +1031,10 @@ public class ElementImpl extends ParentN
this.localName = localName;
}
- /**
- * Sets the namespace.
- *
- * @see org.apache.axiom.om.OMElement#setNamespace (org.apache.axiom.om.OMNamespace)
- */
public void setNamespace(OMNamespace namespace) {
+ if (namespace != null) {
+ namespace = handleNamespace(namespace);
+ }
this.namespace = namespace;
}
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1149153&r1=1149152&r2=1149153&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Thu Jul 21 12:58:19 2011
@@ -28,7 +28,6 @@ import org.apache.axiom.ts.om.container.
import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
-import org.apache.axiom.ts.om.element.TestSetNamespace;
import org.apache.axiom.ts.om.element.TestSetTextQName;
import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
import org.apache.axiom.ts.om.factory.TestCreateOMElementWithInvalidNamespace;
@@ -54,7 +53,7 @@ public class OMImplementationTest extend
builder.exclude(TestInsertSiblingBeforeOnChild.class);
// TODO: DOOM's behavior differs from LLOM's behavior in this case
- builder.exclude(TestCreateOMElementWithGeneratedPrefix.class);
+ builder.exclude(TestCreateOMElementWithGeneratedPrefix.class, "(variant=QName*)");
// DOOM doesn't support CDATA sections
builder.exclude(TestGetXMLStreamReaderCDATAEventFromElement.class);
@@ -77,7 +76,6 @@ public class OMImplementationTest extend
// TODO: investigate why this is not working with DOOM
builder.exclude(TestGetChildrenWithName4.class);
- builder.exclude(TestSetNamespace.class);
// TODO: Need to fix AXIOM-373 first
builder.exclude(TestCreateOMElementWithInvalidNamespace.class);
Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1149153&r1=1149152&r2=1149153&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Thu Jul 21 12:58:19 2011
@@ -183,19 +183,13 @@ public class OMElementImpl extends OMNod
return ns;
}
- /**
- * Method handleNamespace.
- *
- * @return Returns namespace.
- */
private OMNamespace handleNamespace(OMNamespace ns) {
String namespaceURI = ns.getNamespaceURI();
String prefix = ns.getPrefix();
- if (ns.getNamespaceURI().length() == 0 && prefix != null && prefix.length() > 0) {
+ if (namespaceURI.length() == 0 && prefix != null && prefix.length() > 0) {
throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
}
- OMNamespace namespace = findNamespace(ns.getNamespaceURI(),
- ns.getPrefix());
+ OMNamespace namespace = findNamespace(namespaceURI, prefix);
if (namespace == null) {
namespace = declareNamespace(ns);
}
@@ -950,13 +944,11 @@ public class OMElementImpl extends OMNod
}
}
- /** Method setNamespace. */
public void setNamespace(OMNamespace namespace) {
- OMNamespace nsObject = null;
if (namespace != null) {
- nsObject = handleNamespace(namespace);
+ namespace = handleNamespace(namespace);
}
- this.ns = nsObject;
+ this.ns = namespace;
this.qName = null;
}