You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Simon Kitching <si...@ecnetwork.co.nz> on 2004/09/20 00:18:12 UTC
Re: trying to serialize an in memory dom, but do not see a default
namespaces in the output
On Sat, 2004-09-18 at 04:51, Bill Riegel wrote:
>
>
> expect to see
>
>
>
> <DataSet xmlns="someNameSpace">
>
You need to explicitly add xmlns declarations to the DOM you are
building as well as creating the elements in the correct namespace.
Yes this is somewhat clumsy; DOM level 3 has some features that improve
the situation somewhat but with DOM level 2 you definitely need to do
the following to force an "xmlns:msg=...." declaration to be output on
the <foo> tag. I expect some variant of this can be used to output a
"default namespace" declaration, ie "xmlns=....".
// NS_MYMSG = "http://www.acme.com/namespaces/mymessage";
// NS_XMLNS="http://www.w3.org/2000/xmlns/";
Element foo = doc.createElementNS(NS_MYMSG, "msg:foo");
foo.setAttributeNS(NS_XMLNS, "xmlns:msg", NS_MYMSG);
I suggest you search the mail archives for "serialization". There were
two email threads on this topic just last week.
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org