users@jaxb.java.net

Re: attributeGroup ref and annotation

From: Shailender <shailender.bathula_at_AIRNZ.CO.NZ>
Date: Mon, 03 Mar 2003 12:59:50 -0700

Hi Sekhar,

Thanks for your reply. I took the validity of the schema for granted
as it was valid in XML Spy. Is it possible that the RI binding
compiler "xjc" prints a useful error message than just "Failed to parse a
schema" on this validation failure? JAXB 1.0 RI Beta trace is like the one
below. That is how I was able to find out where the problem was in
the first instance.

D:\>xjc Test.xsd
parsing a schema...
Unexpected <xs:annotation> appears at line 7 column 22
  line 7 of Test.xsd

Failed to parse a schema.

Thanks,
Shailender

On Sun, 2 Mar 2003 22:49:44 -0500, Sekhar Vajjhala <sekhar.vajjhala_at_sun.com> wrote:

>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