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 "Matt Aizcorbe (JIRA)" <ax...@ws.apache.org> on 2005/10/13 20:36:04 UTC
[jira] Created: (AXIS-2257) Attribute namespaces and their prefixes don't appear when Serializing using the writeDomElement() call in SerializationContext
Attribute namespaces and their prefixes don't appear when Serializing using the writeDomElement() call in SerializationContext
------------------------------------------------------------------------------------------------------------------------------
Key: AXIS-2257
URL: http://issues.apache.org/jira/browse/AXIS-2257
Project: Apache Axis
Type: Bug
Components: Serialization/Deserialization
Versions: 1.2.1
Environment: Compiling on WinXP box with:
java version "1.4.2_08"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
Reporter: Matt Aizcorbe
Found this issue when using the XMLBeanSerializer/XMLBeanDeserializer which leverages the SerializationContext.writeDOMElement(...). What happens is I am passing in an Element which contains attributes from an assortment of namespaces. The Serialized Document was stripping the namespaces and prefixes for the elements which was breaking my deserializer.
The issue seems to be in the SerializationContext.startElement(...) starting around line 1128. The problem is that no prefix is generated when an attribute has a URI and a qName with no prefix already defined. The small else block below fixes the issue.
if (uri != null && uri.length() > 0) {
if (qname.length() == 0) {
// If qname isn't set, generate one
prefix = getPrefixForURI(uri);
} else {
// If it is, make sure the prefix looks reasonable.
int idx = qname.indexOf(':');
if (idx > -1) {
prefix = qname.substring(0, idx);
prefix = getPrefixForURI(uri,
prefix, true);
}
//start -- added code
else {
prefix = getPrefixForURI(uri,
null, true);
}
//end -- added code
}
if (prefix.length() > 0) {
qname = prefix + ':' + attributes.getLocalName(i);
} else {
qname = attributes.getLocalName(i);
}
} else {
qname = attributes.getQName(i);
if(qname.length() == 0)
qname = attributes.getLocalName(i);
}
--
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
[jira] Updated: (AXIS-2257) Attribute namespaces and their prefixes don't appear when Serializing using the writeDomElement() call in SerializationContext
Posted by "Matt Aizcorbe (JIRA)" <ax...@ws.apache.org>.
[ http://issues.apache.org/jira/browse/AXIS-2257?page=all ]
Matt Aizcorbe updated AXIS-2257:
--------------------------------
Attachment: SerializationContext.java
After a further look, the bug is in the startElement method which is used in basic axis serialization. I have attached the class with the fix.
> Attribute namespaces and their prefixes don't appear when Serializing using the writeDomElement() call in SerializationContext
> ------------------------------------------------------------------------------------------------------------------------------
>
> Key: AXIS-2257
> URL: http://issues.apache.org/jira/browse/AXIS-2257
> Project: Apache Axis
> Type: Bug
> Components: Serialization/Deserialization
> Versions: 1.2.1
> Environment: Compiling on WinXP box with:
> java version "1.4.2_08"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_08-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_08-b03, mixed mode)
> Reporter: Matt Aizcorbe
> Attachments: SerializationContext.java
>
> Found this issue when using the XMLBeanSerializer/XMLBeanDeserializer which leverages the SerializationContext.writeDOMElement(...). What happens is I am passing in an Element which contains attributes from an assortment of namespaces. The Serialized Document was stripping the namespaces and prefixes for the elements which was breaking my deserializer.
> The issue seems to be in the SerializationContext.startElement(...) starting around line 1128. The problem is that no prefix is generated when an attribute has a URI and a qName with no prefix already defined. The small else block below fixes the issue.
> if (uri != null && uri.length() > 0) {
> if (qname.length() == 0) {
> // If qname isn't set, generate one
> prefix = getPrefixForURI(uri);
> } else {
> // If it is, make sure the prefix looks reasonable.
> int idx = qname.indexOf(':');
> if (idx > -1) {
> prefix = qname.substring(0, idx);
> prefix = getPrefixForURI(uri,
> prefix, true);
> }
> //start -- added code
> else {
> prefix = getPrefixForURI(uri,
> null, true);
> }
> //end -- added code
> }
> if (prefix.length() > 0) {
> qname = prefix + ':' + attributes.getLocalName(i);
> } else {
> qname = attributes.getLocalName(i);
> }
> } else {
> qname = attributes.getQName(i);
> if(qname.length() == 0)
> qname = attributes.getLocalName(i);
> }
--
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