Hello all
I have the following schema snippet:
<xs:complexType name="ComponentListType">
<xs:sequence minOccurs="3" maxOccurs="unbounded">
<xs:choice>
<xs:element name="source" type="dx:ComponentType" />
<xs:element name="analyzer" type="dx:ComponentType" />
<xs:element name="detector" type="dx:ComponentType" />
</xs:choice>
</xs:sequence>
<xs:attribute name="count" type="xs:nonNegativeInteger" use="required" />
</xs:complexType>
And I also use external schema bindings to generate Java classes. Here
is a snippet of the bindings.xjb file:
<jxb:bindings node="//xs:complexType[@name='ComponentListType']">
<jxb:class name="ComponentList"/>
</jxb:bindings>
<jxb:bindings node="//xs:complexType[@name='ComponentType']">
<jxb:class name="Component"/>
</jxb:bindings>
When the code is generated, the ComponentList class looks like this:
public class ComponentList {
@XmlElementRefs({
@XmlElementRef(name = "analyzer", type = JAXBElement.class),
@XmlElementRef(name = "source", type = JAXBElement.class),
@XmlElementRef(name = "detector", type = JAXBElement.class)
})
protected List<JAXBElement<Component>> sourceOrAnalyzerOrDetector;
@XmlAttribute(required = true)
@XmlSchemaType(name = "nonNegativeInteger")
protected BigInteger count;
[cut for clarity]
}
While this works, it's ugly. I'm trying to get my schema annotated in
such a way that the class will look like:
@XmlElementRefs({
@XmlElementRef(name = "analyzer", type = Component.class),
@XmlElementRef(name = "source", type = Component.class),
@XmlElementRef(name = "detector", type = Component.class)
})
protected List<Component> components;
All the examples I've seen so far use inline schema annotations but, for
various reasons, I can't use those. I have been unable to find any
documentation on how to use external annotations to get the result I want.
I have tried to use the following external annotation:
<jxb:bindings
node="//xs:complexType[@name='ComponentListType']//xs:sequence//xs:choice">
<jxb:property name="components"/>
</jxb:bindings>
But when I tried to compile the schema with xjc, I get this error:
parsing a schema...
[ERROR] compiler was unable to honor this property customization. It is
attached to a wrong place, or its inconsistent with other
bindings.
line 103 of file:./src/main/resources/bindings.xjb
Any help would be most appreciated.
Cheers,
Rc
--
Richard Cote
Software Engineer - PRIDE Project Team (Sequence Database Group)
European Bioinformatics Institute
Wellcome Trust Genome Campus rcote_at_ebi.ac.uk
Hinxton, Cambridge CB10 1SD Phone: (+44) 1223 492610
United Kingdom