Author: davidillsley
Date: Thu Nov 30 10:20:12 2006
New Revision: 481028
URL: http://svn.apache.org/viewvc?view=rev&rev=481028
Log:
Fix for WSCOMMONS-133
Bring the one of the llom addAttribute methods in line with the other and the
DOOM implementation
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMAttributeHelperTest.java
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?view=diff&rev=481028&r1=481027&r2=481028
==============================================================================
---
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 Nov 30 10:20:12 2006
@@ -523,12 +523,7 @@
if (ns != null) {
namespace = findNamespace(ns.getNamespaceURI(), ns.getPrefix());
if (namespace == null) {
- throw new OMException("Given OMNamespace(" +
ns.getNamespaceURI() + " " +
- ns.getPrefix()
- + ") for "
- +
- "this attribute is not declared in the scope of this
element. First declare the namespace"
- + " and then use it with the attribute");
+ namespace = new OMNamespaceImpl(ns.getNamespaceURI(),
ns.getPrefix());
}
}
return addAttribute(new OMAttributeImpl(attributeName, ns, value,
this.factory));
Modified:
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMAttributeHelperTest.java
URL:
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMAttributeHelperTest.java?view=diff&rev=481028&r1=481027&r2=481028
==============================================================================
---
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMAttributeHelperTest.java
(original)
+++
webservices/commons/trunk/modules/axiom/modules/axiom-tests/src/test/java/org/apache/axiom/om/util/OMAttributeHelperTest.java
Thu Nov 30 10:20:12 2006
@@ -1,5 +1,7 @@
package org.apache.axiom.om.util;
+import javax.xml.namespace.QName;
+
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
@@ -62,5 +64,15 @@
OMElement ome4 = doomf.createOMElement("element",
ns4.getNamespaceURI(), ns4.getPrefix());
AttributeHelper.importOMAttribute(attr4, ome4);
assertSame(attr4, ome4.getAttribute(attr4.getQName()));
+ }
+
+ public void testDetachedElement(){
+ OMNamespace top =
DOOMAbstractFactory.getOMFactory().createOMNamespace("urn:test1", "t1");
+ OMElement ome =
DOOMAbstractFactory.getOMFactory().createOMElement("test", top);
+ OMElement child =
DOOMAbstractFactory.getOMFactory().createOMElement(new QName("test"), ome);
+ OMAttribute oma = child.addAttribute("attr", "value", top);
+
+ OMElement target =
OMAbstractFactory.getOMFactory().createOMElement("test2", "urn:test2", "t2");
+ AttributeHelper.importOMAttribute(oma, target);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]