users@jaxb.java.net

Re: attributeGroup ref and annotation

From: Sekhar Vajjhala <sekhar.vajjhala_at_sun.com>
Date: Sun, 02 Mar 2003 22:49:44 -0500

Shailender wrote:

> I am trying to generate classes for the following schema using
> JAXB 1.0 RI "xjc.bat" and J2SDK1.4 It fails to parse the schema because
> of the annotation element within the attributeGroup ref element.
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="MyElement" type="MyType"/>
>
> <xs:complexType name="MyType">
> <xs:attributeGroup ref="MyAttributeGroup">
> <xs:annotation>
> <xs:documentation>My attribute group</xs:documentation>
> </xs:annotation>
> </xs:attributeGroup>
> </xs:complexType>
>
> <xs:attributeGroup name="MyAttributeGroup">
> <xs:attribute name="MyAttribute" use="required"/>
> </xs:attributeGroup>
> </xs:schema>
>
> D:\>xjc Test.xsd
> parsing a schema...
> Failed to parse a schema.
>
> It works, if I remove the annotation element from the attribuetGroup ref element, like below:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="MyElement" type="MyType"/>
>
> <xs:complexType name="MyType">
> <xs:attributeGroup ref="MyAttributeGroup"/>
> </xs:complexType>
>
> <xs:attributeGroup name="MyAttributeGroup">
> <xs:attribute name="MyAttribute" use="required"/>
> </xs:attributeGroup>
> </xs:schema>
>
> Is this a bug in the RI or a limitation of JAXB that I am not aware of?

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.

 JAXB specification does not specify the semantics of the <documentation>
element within an <annotation>, but it does specify customizations in the
<appinfo> element within an <annotation> element.

>
>
> Thanks,
> Shailender

Sekhar