users@jaxb.java.net

Re: JAXB2 - Problem with marshaling

From: jonathan gold <dev_at_samizdatdigital.org>
Date: Thu, 17 Nov 2005 09:10:45 -0800

what are you passing in to your marshal() method? it looks like you
might be passing in an object of type ProcessSpecificationType, instead
of a JAXBElement< ProcessSpecificationType >. if so, you might try
creating the JAXBElement version and passing it in to the marshal()
method instead to get a root element in your marshalled version. you can
either new() it directly, or use the
ObjectFactory.createProcessSpecification( ProcessSpecificationType value
) method. i'm having to guess a little bit from your description as to
the exact names of your generated types, but this is probably close.

hope this relates to what you're asking and is of some help.

jon

Yavuz Gürcan wrote:
> Hello,
>
> I am currently working on an editor that uses the model of an XSD [1]
> to create an XML representation of a class.
> However, there is a problem. I am trying to create a
> "ProcessSpecification" class and using its functions add a
> "BusinessCollaboration" to it. When I marshal the ProcessSpecification
> before adding anything the XML turns out to be:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
>
> Well, almost nothing I guess.
> After adding items i get:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <BusinessCollaboration name="Untitled" nameID="specify-ID"
> xmlns:ns2="http://docs.oasis-open.org/ebxmlbp/ebbp-2.0"/>
>
> So, the parent does not appear at all. When I add anything else to it
> it becomes something like:
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <BusinessCollaboration name="Untitled" nameID="specify-ID"
> xmlns:ns2="http://docs.oasis-open.org/ebxmlbp/ebbp-2.0"/>
> <BusinessCollaboration name="Untitled2" nameID="specify-ID2"
> xmlns:ns2="http://docs.oasis-open.org/ebxmlbp/ebbp-2.0"/>
>
> This is also a problem, as it does not have a single root.
>
> I would appreciate if anyone could guide me on how to overcome this,
> or provide some possible causes, or even tell me a way to debug this.
>
> Another question is about JAXBElement. This was not present in JAXB 1
> and functions taking specific object were clear (for example
> BusinessCollaboration as input). In JAXB 2, however, almost all
> elements are taken as JAXBElement classes. Is there something I have
> missed? Is this a problem?
>
> Finally, in JAXB 1, the createMarshaller and createUnmarshaller
> functions were available in ObjectFactory. These are not present.
> Instead I am using the marshaller/unmarshaller directly from the JAXB
> libraries. I guess this is the new convention?
>
> The reason to switch to JAXB 2 is that, I had a problem with
> marshaling/unmarshaling of incomplete classes with incomplete (and
> required) fields. Any other suggestion to overcome this situation?
>
> In case you need more information, the jar I used, the src that was
> created with JAXB 2, etc. I can provide these as well.
>
> [1] ebbp 2.0.1 -
> http://www.oasis-open.org/committees/download.php/13907/ebxmlbp-v2.0.1-Schema-cd-en.zip
>
> Thanks in advance.
>
> Best regards,
> --
> Yavuz Gurcan
> Software Engineer
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>