I have the following definitions:
<xsd:complexType name="FilesetType">
<xsd:attribute name="guid" type="GUIDType" use="required"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="description" type="xsd:string"/>
<xsd:attribute name="type" type="FilesetPurposeType" use="required"/>
<xsd:attribute name="envname" type="xsd:ID" use="required"/>
</xsd:complexType>
<xsd:complexType name="RulesetType">
<xsd:complexContent>
<xsd:extension base="FilesetType">
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="load" type="LoadType"/>
<xsd:element name="check" type ="CheckType"/>
</xsd:choice>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="EnumsetType">
<xsd:complexContent>
<xsd:extension base="FilesetType">
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
When I want to unmarshall a document, containing for example:
<ruleset guid="CAFECAFECAFECAFE"
name="Vendor files for package mypack01.eng"
description="Vendor files from the CD My Application Ver. 2.4,
on subdirectory /some/path/here"
type="vendor"
envname="DEPOTDIR">
<check resource="/some/path/goes/here/to/file.msi"
size="120455" version="1.1"/>
<check resource="/some/path/goes/here/to/file.mst"/>
<load resource="/source/path"/>
<load resource="/or/path/to/file.txt"/>
</ruleset>
I receive the error : Unexpected attribute "guid"
I tried changing the attributes order, but I just get then the same error
on the first attribute
<ruleset type="vendor"
guid="CAFECAFECAFECAFE"
name="Vendor files for package mypack01.eng"
description="Vendor files from the CD My Application Ver. 2.4,
on subdirectory /some/path/here"
envname="DEPOTDIR">
<check resource="/some/path/goes/here/to/file.msi"
size="120455" version="1.1"/>
<check resource="/some/path/goes/here/to/file.mst"/>
<load resource="/source/path"/>
<load resource="/or/path/to/file.txt"/>
</ruleset>
would produce : Unexpected attribute "type"
A) Does JAXB support derived types ? If not....will it ever support them ?
I "hack" the error by writing a ValidationEventHandler that ignores
the error if the substring "Unexpected attribute "guid"" is on the
event.getMessage()....but this approach won't work for handling all the
attributes defined in the supertype because some of the attrbutes names are
used in other entities which I want to keep validation.
B) Is there any other solution ?