users@jaxb.java.net

retrieving enumerated values from schema at runtime (jaxb 1.0.5)

From: Robinson Guifo Guifo <rguifo_at_hotmail.com>
Date: Thu, 18 May 2006 11:20:53 +0000

Please note that I am aware of the reflection mechanism
however javax.xml.bind.annotation.XmlType is only available jaxb 1.0.5

I am using jaxb 1.0.5 ( from JWSDP 1.6)

I specified in my xml schema a restriction on values
for attribute typeArea

<xs:element name="Cameroun" type="town"/>

<xs:simpleType name="town">
   <xs:restriction base="xsd:string">
      <xsd:enumeration value="BAFOUSSAM"/>
    </xsd:restriction>
</xsd:simpleType>

Is there a way from the generated java code (using jaxb) to have access to
enumerated value.
conatined in a given xml schema.
Clearly jaxb xml validator is aware of the constant value 'BAFOUSSAM',
because if my Xml constains
a different value for Cameroun element, the jaxb validator rejects it. So I
am interested in having
access to the constant values recorded by the jaxb metadata. I cannot see
any obvious getter
in the jaxb generated java objects framework to cater for my needs.
My current workaround, is to have a xml template, marshall it, record the
constant values
I want, and then use them while working with other xml, which are instances
of the same base xml schema

Please help.
GGR

_________________________________________________________________
Play online games with your friends with MSN Messenger
http://www.join.msn.com/messenger/overview