users@jaxb.java.net

Theoretically inherited attribute not found, ????

From: Laura Ferguson <allenderl_at_acm.org>
Date: Mon, 19 May 2003 17:06:01 -0400

In my schema, I've defined a ComplexType "GroupElement" which has multiple
child classes such as "Label", I must be doing something wrong, because I
keep getting a "unexpected attribute" validation error on the xml I'm
generating with ObjectFactory. Any ideas on what is causing this
error? (I've inlined the error message, the relevant parts of the schema
and the generated xml below.) Many Thanks, Laura Ferguson allenderL_at_acm.org

The error message:
Validation Exception [ERROR]
   Message: unexpected attribute "width"
   In Object: org.nwu.sesp.pdl.impl.LabelImpl_at_14b6bed
   At Line: -1
   At Column: -1
javax.xml.bind.ValidationException
         at
com.sun.xml.bind.validator.ValidatorImpl.validate(ValidatorImpl.java:118)
         at
com.sun.xml.bind.validator.ValidatorImpl.validateRoot(ValidatorImpl.java:85)
         at
org.nwu.sesp.reflectionTool.ReflectionToolMgr.validate(ReflectionToolMgr.java:116)

         at
org.nwu.sesp.reflectionTool.WorksheetMgr.validateCurrentWorksheet(WorksheetMgr.java:164)

         (etc)

But it seems like "width" should be expected because in my schema
definition I have the following ComplexType defined:

<xsd:complexType name="GroupElement">
     <xsd:attribute name="x" type="pdlInteger" use="optional" default="0"/>
     <xsd:attribute name="y" type="pdlInteger" use="optional" default="0"/>
     <xsd:attribute name="width" type="pdlPositiveInteger" use="optional"
default="114"/>
     <xsd:attribute name="height" type="pdlPositiveInteger" use="optional"
default="52"/>
   </xsd:complexType>

Which is then inherited by multiple child classes like this one:
<xsd:element name="Label">
           <xsd:complexType>
             <xsd:complexContent>
               <xsd:extension base="GroupElement">
                 <xsd:sequence>
                   <xsd:element name="dataElement" type="TextDataElement"/>
                    <xsd:sequence>
                               <xsd:annotation>
                                   <xsd:appinfo>
                                      <jxb:property name="comments"/>
                                    </xsd:appinfo>
                               </xsd:annotation>
                               <xsd:element ref="Comment" minOccurs="0"
maxOccurs="unbounded"/>
                        </xsd:sequence>
                 </xsd:sequence>
               </xsd:extension>
             </xsd:complexContent>
           </xsd:complexType>
   </xsd:element>

The generated XML that is created looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<template author="A. N. Author" name="New Template" learner="A. Learner">
         <group name="Default Full View">
                 <Label width="50" y="20" height="10" x="20">
                         <dataElement type="string">&lt;Type your text
here&gt;</dataElement>
                 </Label>
         </group>
</template>