dev@jaxb.java.net

Marshalling an element only marshalls its contents.

From: David Finkbeiner <david_finkbeiner_business_at_yahoo.com>
Date: Tue, 9 Dec 2003 10:06:07 -0800 (PST)

My question is basically the same as item #000122 in
the old JAXB-INTEREST LISTSERV archives
(which was never answered). Take the
modify-marshall sample in jwsdp/jaxb. After
unmarshalling the xml file, if I add the following
lines to Main.java:

            System.out.println("\n\n\n\nFirst the
USAddress");
            m.marshal( po.getBillTo(), System.out );
            System.out.println("\n\n\n\nNext the whole
document");
            m.marshal( po, System.out );


I find that marshalling the whole document (the po
object)
gives the expected results, while marshalling
po.getBillTo() writes out the CONTENTS of the billTo
element, not the billTo element itself (element's
attributes are lost). Furthermore,
the resulting output isn't valid xml. There can only
be 1 root element in an xml document; the marshelled
xml has the <?xml version="1.0" encoding="UTF-8"
standalone="yes"?> followed by several "root" elements
- the contents of billTo. How do I marshel out so
that I get a document with only the billTo element
(with the standard <?xml version... line)?
  
Thanks,
Dave

__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: dev-help_at_jaxb.dev.java.net