users@jaxb.java.net

Re: attributeGroup ref and annotation

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 04 Mar 2003 07:51:55 -0800

> Neither.
>
> Annotation element is not allowed in the reference to the attribute group.
> According to XML Schema Part 1, Section 3.6.2,
> " XML Representation of Attribute Group Definition Schema Components",
> a reference to the attribute group from within a complexType does not correspond to
> any schema component at all. This by extension means that an annotation element is
> not allowed.

I don't think so. While it is true that an attribute group reference
doesn't correspond to any schema component, but the wording doesn't say
it's not allowed, and the synopsis does allow it. Also, it's pretty
clear from schema-for-schema that it is allowed. The fact that Xerces
allows it is yet another evidence that it is allowed.

(from s4s)
 <xs:complexType name="attributeGroupRef">
  <xs:complexContent>
   <xs:restriction base="xs:attributeGroup">
    <xs:sequence>
     <xs:element ref="xs:annotation" minOccurs="0"/>
    </xs:sequence>
    <xs:attribute name="ref" use="required" type="xs:QName"/>
    <xs:attribute name="name" use="prohibited"/>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>

So I think this is a bug of RI (I already fixed it internally), together
with a bug of RI where it fails to produce an error message.

Unfortunately, the only workaround that I can think of is to work a
miniature transformation that strips away those problematic annotations
before you run it through XJC.


regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com