Namespace with no prefix - how? 2003-02-04 - By Jesus M. Salvo Jr.
How do you create a element with a namespace without any prefix, something like this (?):
<Response xmlns="http://mynamespace.org"> <Status>100</Status> </Response>
With the following code:
Element responseElement = doc.createElementNS( "http://mynamespace.org", "Response" );
or
Element responseElement = doc.createElementNS( "http://mynamespace.org", "Response" ); responseElement.setPrefix( "" );
or
Element responseElement = doc.createElementNS( "http://mynamespace.org", "Response" ); responseElement.setPrefix( null );
the output is
<Response> <Status>100</Status> </Response> The only way I can write out the namespace is via:
Element responseElement = doc.createElementNS( "http://mynamespace.org", "Response" ); responseElement.setPrefix( "myprefix" );
.. which output like this:
<myprefix:Response xmlns:myprefix="http://mynamespace.org"> <myprefix:Status>100</myprefix:Status> </myprefix:Response>
but I would preferrably have the xmlns="" without a prefix so that the prefix do not have to be repeated for the child nodes. What am I missing?
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|