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 2003/09/10 02:25:44 UTC
DO NOT REPLY [Bug 23044] New: -
No way to non-default namespace prefixes when creating MessageElements from DOM elements
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=23044>.
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=23044
No way to non-default namespace prefixes when creating MessageElements from DOM elements
Summary: No way to non-default namespace prefixes when creating
MessageElements from DOM elements
Product: Axis
Version: 1.1
Platform: All
OS/Version: All
Status: NEW
Severity: Minor
Priority: Other
Component: Serialization/Deserialization
AssignedTo: axis-dev@ws.apache.org
ReportedBy: mark.peskin@hp.com
I have noticed that there is no way to keep AXIS from using the default "ns#"
namespace prefix when creating MessageElements (e.g. SOAP header elements)
from DOM elements. This is because:
1) The prefix used in the DOM element is ignored by
SerializationContextImpl.writeDOMElement(). It does not call
registerPrefixForURI().
AND
2) MessageElement.setPrefix() is also ignored in this case. This is because,
when the MessageElement has been constructed from DOM,
MessageElement.outputImpl() short circuits immediately *before* getting to the
line where registerPrefixForURI() is called based on the prefix value (line
806 & 807 in MessageElement.java). Note that this could easily be fixed by
moving lines 806-821 to the *beginning* of the MessageElement.outputImpl()
method. i.e.:
protected void outputImpl(SerializationContext context) throws Exception
{
if (prefix != null)
context.registerPrefixForURI(prefix, namespaceURI);
if (namespaces != null) {
for (Iterator i = namespaces.iterator(); i.hasNext();) {
Mapping mapping = (Mapping) i.next();
context.registerPrefixForURI(mapping.getPrefix(),
mapping.getNamespaceURI());
}
}
if (elementRep != null) {
boolean oldPretty = context.getPretty();
context.setPretty(false);
context.writeDOMElement(elementRep);
context.setPretty(oldPretty);
return;
}
if (textRep != null) {
boolean oldPretty = context.getPretty();
context.setPretty(false);
context.writeSafeString(textRep.getData());
context.setPretty(oldPretty);
return;
}
if (objectValue != null) {
context.serialize(new QName(namespaceURI, name),
attributes,
objectValue, null, false, Boolean.TRUE);
return;
}
context.startElement(new QName(namespaceURI, name), attributes);
if (children != null) {
for (Iterator it = children.iterator(); it.hasNext();) {
((MessageElement)it.next()).output(context);
}
}
context.endElement();
}