users@jaxb.java.net

RE: How does JAXB handle enumeration?

From: Sam Cheung <sylcheung_at_hotmail.com>
Date: Sat, 14 Feb 2004 00:15:11 +0000

Thanks. This is odd.

I have this in my schema:
        <xs:simpleType name="priorityType">
                <xs:annotation>
                        <xs:documentation>Priority of MM</xs:documentation>
                </xs:annotation>
                <xs:restriction base="xs:string">
                        <xs:enumeration value="Normal"/>
                        <xs:enumeration value="High"/>
                        <xs:enumeration value="Low"/>
                </xs:restriction>
        </xs:simpleType>

And in my javacode, I try to set the Prority to "ABC" on purpose,
           sr.setPriority("ABC");
and then later on marshall it,
   JAXBContext jc = JAXBContext.newInstance("mm7");

            Marshaller m = jc.createMarshaller();
            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            m.marshal(sr,baos);

it does let me do that. I don't see any exception when I run the program.



-----Original Message-----
From: Geis, Matt [mailto:Matt.Geis_at_schwab.com]
Sent: Friday, February 13, 2004 5:59 PM
To: 'users_at_jaxb.dev.java.net'
Subject: RE: How does JAXB handle enumeration?


JAXB handles enumerations very well. You don't have to turn it on, per se.
Just use it in your schema, and the validation on marshalling and
unmarshalling will catch it. You would have to tell JAXB to validate,
however.

-----Original Message-----
From: Sam Cheung [mailto:sylcheung_at_hotmail.com]
Sent: Friday, February 13, 2004 3:37 PM
To: users_at_jaxb.dev.java.net
Subject: How does JAXB handle enumeration?

Hi,

Does JAXB generate an C-like enum in Java for each enumeration in the
schema?
By default, I don't think it does it. Is there such a feature? if yes, is
there a way to turn that on?
I believe xmlbeans does it, I am wondering if JAXB can do this also.

Thank you.

<xs:restriction base="xs:string">
                        <xs:enumeration value="Expired"/>
                        <xs:enumeration value="Retrieved"/>
                        <xs:enumeration value="Rejected"/>
                        <xs:enumeration value="Indeterminate"/>
                        <xs:enumeration value="Forwarded"/>
</xs:restriction>

_________________________________________________________________
Plan your next US getaway to one of the super destinations here.
http://special.msn.com/local/hotdestinations.armx


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

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

_________________________________________________________________
Find great local high-speed Internet access value at the MSN High-Speed
Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/


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