1

I have a schema with two elements within a <xs:choice/> block, as per the following fragment:

<xs:complexType name="POCD_MT000040.Component2">
    <xs:sequence>
        <xs:element name="realmCode" type="CS" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="typeId" type="POCD_MT000040.InfrastructureRoot.typeId" minOccurs="0"/>
        <xs:element name="templateId" type="II" minOccurs="0" maxOccurs="unbounded"/>
        <xs:choice>
            <xs:element name="nonXMLBody" type="POCD_MT000040.NonXMLBody"/>
            <xs:element name="structuredBody" type="POCD_MT000040.StructuredBody"/>
        </xs:choice>
    </xs:sequence>
    <xs:attribute name="nullFlavor" type="NullFlavor" use="optional"/>
    <xs:attribute name="typeCode" type="ActRelationshipHasComponent" use="optional" fixed="COMP"/>
    <xs:attribute name="contextConductionInd" type="bl" use="optional" fixed="true"/>
</xs:complexType>

This is part of the HL7/CDA specification schemas, by the way.

Well, I am using maven-jaxb2-plugin to generate the Java classes, with a touch of the jaxb2-basics plugin to simplify complex elements, like nonXMLBody and structuredBody. Let's say I have a bindings file with the following contents:

<jxb:bindings
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:simplify="http://jaxb2-commons.dev.java.net/basic/simplify"
    jxb:extensionBindingPrefixes="xjc simplify"
    version="2.1">

    <jxb:globalBindings
        typesafeEnumMaxMembers="1000"
        generateMixedExtensions="true"
        generateIsSetMethod="true"
        choiceContentProperty="true">

        <xjc:serializable uid="1" />
    </jxb:globalBindings>

    <jxb:bindings schemaLocation="xsd/POCD_MT000040.xsd">
        <jxb:bindings node="xs:complexType[@name='POCD_MT000040.Component2']//xs:choice">
            <simplify:as-element-property />
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

The attributes are generated as expected:

protected POCDMT000040NonXMLBody nonXMLBody;
protected POCDMT000040StructuredBody structuredBody;

However, although I am using generateIsSetMethod="true" in the global bindings, the methods isSetNonXMLBody ( ) and isSetStructuredBody ( ) are not being generated at all. The equivalent methods for the rest of the attributes are present, though, like isSetTypeId ( ).

Am I missing any option I should know of to generate these methods in the aforementioned elements?

pcesarperez
  • 67
  • 1
  • 8

0 Answers0