Kohsuke Kawaguchi wrote:
>>Is there a way I can read an schema file to get meta data information?
>>Assuming I have schema that allows an element to have only 2 values
>>(VALUE1 and VALUE2), can I get these allowable values out of the schema
>>- so that I can put them in some UI widget (JCombobox maybe).
>
>
> Being able to parse a schema file and inspect definitions in it would be
> useful by itself, so chances are somebody already has developed such a
> library. Just google it and you would probably find something.
>
> JAXB internally uses XML Schema object model library, and I'd like to
> release it as a standalone library, but at this moment I'm not sure if
> that will happen. I also wrote Multi-Schema Validator which gives you
> some degree of schema reflection. Castor and several other vendors have
> schema object model by themselves, so you might want to check them out,
> but none of them are quite good IMHO.
>
>
> If you just need to list up the options of an enumeration, it seems to
> me that you don't really need to go all the way down to XML Schema. You
> can just use Java reflection
To follow up on this solution, JAXB provides a capability to map XML simple
datatypes with enum facets to the Java typesafe enum design pattern. You can
read up on this feature in the JAXB specification in sections 4.3, 5.2.3 and 6.10.
Once you have mapped your xml datatype with enum facets to a typesafe
enum, you could use java reflection to get the members of the typesafe enum
and display these in the combo box.
We have received requests for an iterator over the typesafe enum enumerators
and will considering adding this support in a future release.
-Joe Fialli, Sun Microsystems
>
>
>
> regards,
> --
> Kohsuke KAWAGUCHI 408-276-7063 (x17063)
> Sun Microsystems kohsuke.kawaguchi_at_sun.com
--