users@jaxb.java.net

Re: xs:restriction / xs:enumeration without Enumeration ?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 14 May 2007 17:27:44 -0700

There has been some discussion of defining annotations to represent
facets like this, then update XJC/schemagen accordingly to take
advantage of those.

Looking for a volunteer to work on this...

Henri Gomez wrote:
> A very usefull feature in JAXB/JAXWS in code first approach is to use
> Enumeration to define some specific set in XML-SCHEMA ie :
>
> @XmlAccessorType(XmlAccessType.FIELD)
> @XmlType(name = "AchatVente", namespace = "http://myapp/services/v1/")
> public enum BuySell {
> B("B"), S("S");
>
> private String value;
>
> BuySell (String v) {
> value = v;
> }
>
> public String value() {
> return value;
> }
>
> public static BuySell fromValue(String value) {
> for( BuySell av : BuySell .values() ) {
> if ( av.value().equals(value) )
> return av;
> }
>
> return A;
> }
> }
>
>
> ==>
>
> <xs:simpleType name="BuySell ">
>
> <xs:restriction base="xs:string">
> <xs:enumeration value="B"/>
> <xs:enumeration value="S"/>
> </xs:restriction>
> </xs:simpleType>
>
>
> Did there is a way to do the same dynamically
> (xs:restriction/xs:enumeration), not using Enumeration but using
> standard Java classes (these one grabbing their possible values at
> runtime, ie from SQL backend).
>
> Regards
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com