/Ali, Haneef/:
Consider the following code?
a) Element env = Document.createElementNS("soapnamespace",
"soap:Envelope");
b) env.setAttribute("xmls:soap", 'soapnamespace");
A) Do we really needs to make the call "setAttribute(...)
B) If we don't make that call then serialization with
org.apache.xml.serialize.XMLSerializer and JAXP Transformer doesn't add
the namespace attribute
DOM 2 has different namespace considerations [1] than DOM 3 and
leave the maintenance of the namespace declaration attributes to the
user application. DOM 3 LS however specifies
<http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-LSSerializer>:
Namespaces are fixed up during serialization, the serialization
process will verify that namespace declarations, namespace prefixes
and the namespace URI associated with elements and attributes are
consistent. If inconsistencies are found, the serialized form of the
document will be altered to remove them. The method used for doing
the namespace fixup while serializing a document is the algorithm
defined in Appendix B.1, "Namespace normalization" [2], of [DOM
Level 3 Core].
/Ali, Haneef/:
C) If we add that setAttribute call, then DOM3 ( DOMLSImplementaion)
DOMSerializer adds two xmlns attributes.
(ie) <soap:Enveope xmlns:soap="soapEnvelope"
xmlns:soap="soapEnvelope' />
So, given the above it could be an error on the serializer part but
I'm not really sure if the correct behavior is guaranteed only when
serializing DOM 3 created nodes.
D) Assume if we go with DOM3 serialization and don't do
setAttribute(...), then how will you append a textNode which is a qName.
(ie) Element env = Document.createElementNS("wsrfnamepace",
"wsrf:GetResourceProperty");
Qname myQName = new Qname("myNamespace", "myElement");
How to append the qName?
Whatever serialization you go with text nodes are just character
data. You add the text you wish in the normal way:
Document doc;
...
env.appendNode(doc
.createTextNode("myNamespace" + ":" + "myElement");
or using the DOM 3 interfaces:
env.setTextContent("myNamespace" + ":" + "myElement");
[1]
http://www.w3.org/TR/DOM-Level-2-Core/core.html#Namespaces-Considerations
[2]
http://www.w3.org/TR/DOM-Level-3-Core/namespaces-algorithms.html#normalizeDocumentAlgo
--
Stanimir
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]