users@jaxb.java.net

Re: Marshaller not writing namespace information

From: Tonio <toniocus_at_gmail.com>
Date: Tue, 12 Aug 2008 12:50:33 -0700 (PDT)

Sorry this is MY MISTAKE.

I'm still getting confused between "xsi:type" and element.

In my example although policy is defined in its namespace, element
policy inside the message element is not defined
in any namespace yet.

So everything is OK.

Thanks to everybody that simply bother himself to read this message
tonio


Tonio wrote:
>
> Hi,
>
> <p>I have a really big problem, I'm constructing an xml from Java Mapped
> Classes
> and no information about namespace is written to the output, so the result
> is
> not a well-written XML just some nicely formatted string :-).
>
> <p>I'm using jvm 1.6.0_05 with whatever JAXB version it has.
>
> <p>I have my Mapped Classes in a jar file, each package has his own
> package-info.java with the XmlSchema tag defined, NO ObjectFactory.
>
> Basically my application does something like:
>
> <pre>
> ------------------------------------------------------------------------------------------------------
> Code Snippet
> ------------------------------------------------------------------------------------------------------
> package test.xml;
>
> import biz.Policy; // mapped classes with their own namespace in
> package-info.java
>
> public class Execute {
>
> public void writeXml(Policy pol) throws Exception {
> JAXBContext ctx=JAXBContext.newInstance(Envelope.class);
>
> Envelope envelope=new Envelope();
> envelope.policy = pol;
>
> Marshaller mm = ctx.createMarshaller();
> mm.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
>
> mm.marshall(envelope, {output});
> }
>
> @XmlRootElement(namespace="http://www.xxx.org/xsd/test-cases")
> public static class Envelope {
>
> @XmlElement
> @XmlElementWrapper(name="list")
> public Policy policy;
> }
>
> }
>
> ------------------------------------------------------------------------------------------------------
> Resulting xml (sorry for the [])
> ------------------------------------------------------------------------------------------------------
> [ns2:envelope xmlns:ns2="http://www.xxx.org/xsd/test-cases"]
> [list] [!-- no namespace prefix here !!!!! --]
> [policy] [!-- no namespace !!!!! --]
> ........policy data...........
> [/policy]
> [/list]
> [/ns2:envelope]
>
> </pre <p>If I generate the schemas for my envelope class, all things
> seems well written, so I'm a bit lost of what is happening.
>
> <p>Some clue of what I'm missing that makes JAXB
> miss the policy and list namespace in my resulting XML ?
>
> <p>Thanks in advance
> tonio
>

-- 
View this message in context: http://www.nabble.com/Marshaller-not-writing-namespace-information-tp18833052p18951448.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.