users@jaxb.java.net

<xsd:extension> causes validation error

From: Filip Rindler <filip.rindler_at_gmx.de>
Date: Thu, 05 Jun 2003 16:22:38 +0200

Hi!

I'm having another problem with the <xsd:extension> feature of XML schema:

Here's an excerpt from my schema again:

<xsd:complexType name="Matrix">
 <xsd:attribute name="className" type="xsd:string" />
</xsd:complexType>

<xsd:complexType name="Matrix2DGrid">
 <xsd:complexContent>
  <xsd:extension base="Matrix">
   <xsd:all>
    <xsd:element name="size" type="Matrix2DGridDimension" />
    <xsd:element name="neighborhoodRelation" type="xsd:int" />
    <xsd:element name="cells" type="CellsList" />
   </xsd:all>
  </xsd:extension>
 </xsd:complexContent>
</xsd:complexType>

And here's an XML file that was generated (and validated) using
JAXB-generated classes:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns1:mtxfile
xsi:schemaLocation="http://www.filip-rindler.de/cytorit/xml/mtxfile
http://www.filip-rindler.de/cytorit/xml/mtxfile.xsd"
xsi:noNamespaceSchemaLocation="http://www.filip-rindler.de/cytorit/xml/mtxfi
le http://www.filip-rindler.de/cytorit/xml/mtxfile.xsd"
xmlns:ns1="http://www.filip-rindler.de/cytorit/xml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ns1:minVersion>100</ns1:minVersion>
<ns1:matrix className="de.filiprindler.cytorit.standard.Matrix2DGrid">
<--- HERE
<ns1:size>
<ns1:origin>
<ns1:x>1</ns1:x>
<ns1:y>1</ns1:y>
</ns1:origin>
<ns1:width>10</ns1:width>
<ns1:height>10</ns1:height>
</ns1:size>
<ns1:neighborhoodRelation>1</ns1:neighborhoodRelation>
<ns1:cells></ns1:cells>
</ns1:matrix>
<ns1:parameters></ns1:parameters>
</ns1:mtxfile>

However, when reading the document I get a
[com.sun.msv.verifier.ValidityViolation: unexpected attribute "className"]
exception!
How is this possible that I can successfully validate and save the file but
when reding it, i get this exception?
I think it has something to do with the fact that the className attribute
has been derived from the Matrix complexType to the Matrix2DGrid subtype.

Thanks!

Filip Rindler