Hi,
I would like to report the recurrence of (closed) bug 4800069 in the RI. It involves validation of a simple inheritance structure in which the base class has an attribute specified. While I believe the original bug report describes the same issue, my method of generating the exception involves unmarshalling instead of on demand validation. The schema is as follows:
<?xml version="1.0"?>
<xsd:schema xmlns:xsd="
http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xsd:complexType name="Model">
<xsd:attribute name="id" type="xsd:int" use="required"/>
</xsd:complexType>
<xsd:complexType name="DataPointer">
<xsd:complexContent>
<xsd:extension base="Model">
<xsd:sequence>
<xsd:element name="type" type="xsd:string"/>
</xsd:sequence>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:element name="pointer" type="DataPointer"/>
</xsd:schema>
This schema is legal and compiles fine. I am using the following code to do an unmarshal:
File file = new File( args[0] );
InputStream in = new FileInputStream( file );
JAXBContext jc = JAXBContext.newInstance( "datapointer" );
Unmarshaller u = jc.createUnmarshaller();
u.setValidating( true );
u.unmarshal( in );
The XML file being unmarshalled:
<?xml version="1.0" encoding="UTF-8"?>
<pointer id="1">
<type>check</type>
</pointer>
The following exception is thrown:
DefaultValidationEventHandler: [ERROR]: unexpected attribute "id"
com.sun.msv.verifier.ValidityViolation: unexpected attribute "id"
at com.sun.msv.verifier.Verifier.onError(Verifier.java:319)
at com.sun.msv.verifier.Verifier.onError(Verifier.java:315)
at com.sun.msv.verifier.Verifier.feedAttribute(Verifier.java:259
...
--------------- linked to ------------------
javax.xml.bind.UnmarshalException
- with linked exception:
[com.sun.msv.verifier.ValidityViolation: unexpected attribute "id"]
...
I have validated the XML against the schema using MSV (ver 20030225), XSV, and XMLSpy, and all report no problems. I am running this on Java 1.4.0b92. Any help here would be much appreciated. Please let me know if I should file another bug report for this or the problem reported on Friday 11th.
TIA,
Craig