You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by bu...@apache.org on 2002/10/31 16:54:31 UTC
DO NOT REPLY [Bug 14134] New: -
QName Attributes lose namespace mapping in MessageElement after Serialization.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14134>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14134
QName Attributes lose namespace mapping in MessageElement after Serialization.
Summary: QName Attributes lose namespace mapping in
MessageElement after Serialization.
Product: Axis
Version: 1.0
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@xml.apache.org
ReportedBy: chrisw@wolfram.com
When addAttribute(String namespace, String localPart, QName qname) is called on
a MessageElement, the attribute is set correctly within the MessageElement.
During the first serialization of the attribute, it serializes it correctly
adding the correct namespace declarations. However, in additional
serializations, the namespace declaration is lost. And the prefix for the
attribute remains what it was in the previous serialization.
Example....
### QNameAttrTest.java ###
import org.apache.axis.message.MessageElement;
import javax.xml.namespace.QName;
public class QNameAttrTest
{
public QNameAttrTest()
{
}
public static void main(String[] args)
{
try
{
MessageElement me =
new MessageElement("http://www.wolfram.com","Test");
me.addAttribute(
"http://www.w3.org/2001/XMLSchema-instance",
"type",
new QName("http://www.wolfram2.com", "type1"));
MessageElement me2 =
new MessageElement("http://www.wolfram.com", "Child", (Object)"1");
me2.addAttribute(
"http://www.w3.org/2001/XMLSchema-instance",
"type",
new QName("http://www.w3.org/2001/XMLSchema", "int"));
me.addChildElement(me2);
System.out.println(me.toString());
System.out.println(me.toString());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
Result (I fixed up the xml to make it more readible)...
<ns2:Test xsi:type="ns1:type1"
xmlns:ns1="http://www.wolfram2.com"
xmlns:ns2="http://www.wolfram.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns2:Child xsi:type="xsd:int"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
1
</ns2:Child>
</ns2:Test>
<ns1:Test xsi:type="ns1:type1"
xmlns:ns1="http://www.wolfram.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:Child xsi:type="xsd:int">
1
</ns1:Child>
</ns1:Test>
You will notice that the first elements seem to be set correctly. The types
look correct and all the namespaces are declared. In the second element, the
type is set, but it is set with the wrong prefix. It is set
to "http://www.wolfram.com" rather than "http://www.wolfram2.com" as
specified. This is because ns1 went away from the first call, and the prefix
remained the same in the second call. Therefor an incorrect type was set.