OMElement has incorrect namespace after adding OMAttribute
----------------------------------------------------------
Key: WSCOMMONS-114
URL: http://issues.apache.org/jira/browse/WSCOMMONS-114
Project: WS-Commons
Issue Type: Bug
Components: AXIOM
Environment: Using Axiom 1.1.1 binary distribution, Java 1.4.2_12,
Windows XP Professional
Reporter: Jeehong Min
Priority: Critical
Run the code below that reproduces the issue. Note that the namespace of child
is changed to "" after adding the attribute. This appears to be a regression
since Axiom 1.0.
----
import java.io.*;
import org.apache.axiom.om.*;
public class AttributeHandling {
public static void main(String args[]) {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace ns = fac.createOMNamespace("urn:foo", "");
OMElement titleElem = fac.createOMElement("title", ns);
OMNamespace ns2 = fac.createOMNamespace("urn:foo", "");
OMElement childElem = fac.createOMElement("child", ns2);
childElem.setText("boy");
titleElem.addChild(childElem);
String xml = titleElem.toString();
// expect <title xmlns="urn:foo"><child>boy</child></title>
System.out.println("xml = " + xml);
// add attribute id="2"
OMNamespace idNs = fac.createOMNamespace("", "");
OMAttribute attr = fac.createOMAttribute("id", idNs, "2");
childElem.addAttribute(attr);
xml = titleElem.toString();
// expect <title xmlns="urn:foo"><child id="2">boy</child></title>
System.out.println("xml 2 = " + xml);
OMOutputFormat format = new OMOutputFormat();
String charSetEnc = "UTF-8";
format.setCharSetEncoding(charSetEnc);
format.setSOAP11(true);
format.setDoOptimize(false);
try {
ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
titleElem.serializeAndConsume(bytesOut, format);
xml = new String(bytesOut.toByteArray());
// expect <title xmlns="urn:foo"><child id="2">boy</child></title>
System.out.println("xml 3 = " + xml);
} catch (Exception e) {
e.printStackTrace();
}
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]