users@jaxb.java.net

JAXB2 - Problem with marshaling

From: Yavuz Gürcan <yavuz.gurcan_at_gmail.com>
Date: Thu, 17 Nov 2005 16:20:00 +0200

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