users@jaxb.java.net

restriction of a type containing a "ref" element

From: François Banel <francois.banel_at_FILINKS.COM>
Date: Mon, 02 Jun 2003 04:51:36 -0600

Hello,

I think I have found a bug in the JAXB 1.0 version.
I have not found any reference to that problem in previous messages,
so I post it :

in the same namespace, I define an element TimeLimit, and types OrderType
and SimpleOrderType.
OrderType contains a ref to a TimeLimit element.
SimpleOrderType is a restriction of OrderType, containing also the TimeLimit element.

Then by unmarshalling a correct XML file (correct for XMLSpy, but it appears to be simple enough to be correct anyway), I obtain an object
which cannot be validated by JAXB.

The Validation Handler message is :
message= "tag name "TimeLimit" is not allowed. Possible tag names are: <com.testfb.datamodel.restriction.TimeLimit>"

Am I wrong in defining the schema or is it an error from JAXB ?


The sample schema file :

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.datamodel.testfb.com/restriction" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:res="http://www.datamodel.testfb.com/restriction" jxb:version="1.0">

 <element name="TimeLimit">
  <complexType>
   <sequence>
    <element name="ExpiryDate" type="date" minOccurs="0"/>
   </sequence>
   <attribute name="LimitType" type="string"/>
  </complexType>
 </element>

 <complexType name="OrderType">
  <sequence>
   <element ref="res:TimeLimit" minOccurs="0"/>
  </sequence>
 </complexType>


 <complexType name="SimpleOrderType">
  <complexContent>
   <restriction base="res:OrderType">
    <sequence>
     <element ref="res:TimeLimit" minOccurs="0"/>
    </sequence>
   </restriction>
  </complexContent>
 </complexType>
 <element name="Order" type="res:SimpleOrderType"/>
</schema>


The sample xml file :
<?xml version="1.0" encoding="UTF-8"?>
<res:Order xmlns:res="http://www.datamodel.testfb.com/restriction" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.datamodel.testfb.com/restriction
C:\order_restriction.xsd">
 <res:TimeLimit LimitType="String">
  <ExpiryDate>1967-08-13</ExpiryDate>
 </res:TimeLimit>
</res:Order>