users@jaxb.java.net

map xsd:restrictions as subclasses

From: <anca.a.dobrescu_at_gmail.com>
Date: Thu, 12 May 2011 15:48:47 +0000 (GMT)

Hi everyone -

I have been doing a lot of research trying to figure this out, but am
still unsuccessful.

Here's what I'm trying to do. I have a number of XSD that follow this
pattern:

Simple_Id.xsd

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
        <xsd:include schemaLocation="./Base_3039.xsd"/>
        <xsd:include schemaLocation="./Simple_A.xsd"/>
        <xsd:include schemaLocation="./Simple_S.xsd"/>
        <xsd:include schemaLocation="./Simple_N.xsd"/>
        <xsd:include schemaLocation="./Simple_V1.xsd"/>
        <xsd:include schemaLocation="./Simple_L.xsd"/>
        <xsd:include schemaLocation="./Simple_V.xsd"/>
        <xsd:include schemaLocation="./Simple_C.xsd"/>
        <xsd:simpleType name="Simple_Id">
                <xsd:restriction base="Base_3039"/>
        </xsd:simpleType>
</xsd:schema>

where for example Simple_S.xsd looks like this:

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">

<xsd:include schemaLocation="./Simple_Id.xsd"/>

<xsd:simpleType name="Simple_S">
      <xsd:restriction base="Simple_Id">

                <xsd:minLength value="14"/>
                <xsd:maxLength value="14"/>

      </xsd:restriction>
</xsd:simpleType>

</xsd:schema>

Eventually, I would like to be able to generate XML files that contain
tags looking like this:

<Id xsi:type="Simple_S">XYZUVW</Id>

For now, without enabling mapSimpleTypeDef, I am able to
marshall/unmarshall XML files but without the xsi:types.

After enabling mapSimpleTypeDef classes are generated for the simple
types. Nevertheless, the classes for the different types of Simple_Ids
do not extend Simple_Id but only contain a field of type Simple_Id.

So, basically, my question is how can I make JAXB map my restrictions
as subclasses of the restricted type. Note that the XSDs are not mine
to modify, just have to work with them.

Thanks for taking the time to help me figure this out!

-Anca