users@jaxb.java.net

Re: unmarshalling annotated beans to DOM

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 30 Jul 2007 13:57:40 -0700

Yassine ELassad wrote:
> Hi list,
> i have made some reading on jaxb and i hope that i get it right
> what i understood is that i can use jaxb for following cases:
>
> 1)
>
> xsd --(use jaxb to generate) ---> Java Classes and Interfaces
>
> 2)
> (Java Classes and Interfaces)--(use jaxb to create)-->(XML|DOM|..)
>
> i have the following problem:
>
> i have managed to create an annotated bean generator based on an xsd
> like xml file
>
> following example show a generated bean:
>
> -- -- -- -- code -- -- -- --
>
> import javax.xml.bind.annotation.XmlElement;
> import javax.xml.bind.annotation.XmlRootElement;
>
> @XmlRootElement
> public class CFGACE {
>
> @XmlElement(name = "accessMask")
> private long accessMask = 0;
>
> public void setAccessMask(long accessMask) {
> this.accessMask = accessMask;
> }
>
> public long getAccessMask() {
> return accessMask;
> }
>
> }
>
> -- -- -- -- code Java-- -- -- --
>
> based on this part of an xml file:
>
> -- -- -- -- code XML -- -- -- --
> ..
> !-- CfgACE **************************************** -->
>
> <type_info name="CfgACE" class="structure" id="CFGACE">
> <attribute name="ID" style="object" mapping =
> "ID" libid="CFGAccessID" ref="CfgACEID"/>
> <attribute name="accessMask" style="ulong" mapping =
> "accessMask" libid="CFGAccessMask" />
> </type_info>
>
> <!-- CfgACE **************************************** -->
> ..
> -- -- -- -- code XML -- -- -- --
>
> my target is being able to create Dom out of the bean above and i wonder
> if i can use jaxb for creating dom objects out of beans like the one above

Sure. Just use the marshal method that works with DOM.

> the bean above is a simple case i have beans where I'm using own types
> like List<OwnType> objects; etc...
>
>
> TIA & greetings
> Yassine
>
>
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com