Hi Andy,

[email protected] wrote:

> Hi
> 
> I'm a noob to xstream and stuck on adding some XMLNS details. I am using
> Writer + ObjectOutputStream to create a rather large XML file. I've got
> the hang of most of it but want to add some xmlns details to the root
> node/element.
> 
> My code is
> 
> writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
> ObjectOutputStream outStream = xstream.createObjectOutputStream(writer,
> "n:job_SSDIF")
> 
> 
> Which creates the following for me:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <n:job__SSDIF> (note the double underscore as well???)

Underscore is the escape character, see FAQ. 
 
> I want the root node to actually look like this
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <n:job_SSDIF xmlns:n="urn:job"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> xsi:schemaLocation="urn:job http://beta.job.local/csv2xml/SSDIF.XSD";>
> 
> The name space isn't actually used in the XML (the specifications comes
> from a client) so I basically just need to add this somehow, what is the
> best way of doing this?

You have to use a driver that is supporting namespaces i.e. a StAX-based 
one. See StaxDriver and derived.

Cheers,
Jörg


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to