jaxb
  1. jaxb
  2. JAXB-387

Unable to override xjc-generated getter name for a choice collection

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.1.3
    • Fix Version/s: not determined
    • Component/s: xjc
    • Labels:
      None
    • Environment:

      Operating System: Linux
      Platform: All

      Description

      The schema below generates a cumbersome getter property name for the choice
      collection (getAppointmentsAndAwaiesAndBreakfasts()).
      I am unable to override the name thru annotations in either the
      bindings file or in the schema file itself. I used the <jxb:property name='X'>
      annotation.
      In both cases I see the error:
      compiler was unable to honor this property customization.
      It is attached to the wrong place or is inconsistent with other bindings

      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema targetNamespace="urn:ietf:params:xml:ns:pidf:rpid"
      xmlns="urn:ietf:params:xml:ns:pidf:rpid"
      xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
      xmlns:xs="http://www.w3.org/2001/XMLSchema"
      xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
      jaxb:version="1.0"
      elementFormDefault="qualified" attributeFormDefault="unqualified">

      <xs:element name="activities">
      <xs:annotation>
      <xs:documentation>
      Describes what the person is currently doing, expressed
      as an enumeration of activity-describing elements. A
      person can be engaged in multiple activities at the same
      time, e.g., traveling and having a meal.
      </xs:documentation>
      </xs:annotation>

      <xs:complexType>
      <xs:sequence>
      <xs:element name="note" type="Note_t" minOccurs="0"
      maxOccurs="unbounded" />
      <xs:choice>
      <xs:element name="unknown" type="empty"
      minOccurs="0" />
      <xs:sequence maxOccurs="unbounded">
      <xs:choice>
      <xs:annotation>
      <xs:appinfo>
      <!-- <jaxb:property name="activityList"/> -->
      </xs:appinfo>
      </xs:annotation>
      <xs:element name="appointment" type="empty" />
      <xs:element name="away" type="empty" />
      <xs:element name="breakfast" type="empty" />
      <xs:element name="busy" type="empty" />
      <xs:element name="dinner" type="empty" />
      <xs:element name="holiday" type="empty" />
      <xs:element name="in-transit" type="empty" />
      <xs:any namespace="##other"
      maxOccurs="unbounded" processContents="lax" />
      </xs:choice>
      </xs:sequence>
      </xs:choice>
      </xs:sequence>
      <xs:anyAttribute namespace="##any" processContents="lax" />
      </xs:complexType>
      </xs:element>

      <xs:element name="class" type="xs:token">
      <xs:annotation>
      <xs:documentation>
      Describes the class of the service, device or person.
      </xs:documentation>
      <xs:appinfo>
      <jaxb:class name="PresenceClass" />
      </xs:appinfo>
      </xs:annotation>
      </xs:element>

      <xs:complexType name="Note_t"/>

      <xs:complexType name="empty" />

      </xs:schema>

        Activity

        Hide
        kohsuke added a comment -

        Added as91-na

        Show
        kohsuke added a comment - Added as91-na
        Hide
        karl92 added a comment -

        Same behavior with the sample below and with jaxb ri version 2.1.3 and 2.1.4

        Here is an extract of my sample schema :

        <xs:element name="VehicleObjects">
        <xs:complexType>
        <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element ref="CarObject"/>
        <xs:element ref="TruckObject"/>
        </xs:choice>
        </xs:complexType>
        </xs:element>

        Without property customization, xjc generates the following java source :
        @XmlRootElement(name = "VehicleObjects")
        public class VehicleObjects {

        @XmlElements(

        { @XmlElement(name = "CarObject", type = CarObject.class), @XmlElement(name = "TruckObject", type = TruckObject.class) }

        )
        protected List<VehicleObject> carObjectsAndTruckObjects;

        I wanted to rename the ugly 'carObjectsAndTruckObjects' name into
        'vehicleObjectList'
        by using the following external bindings :

        <jxb:bindings schemaLocation="myschema.xsd" node="/xs:schema">
        <jxb:schemaBindings>
        <jxb:package name="com.sample.jaxb"/>
        </jxb:schemaBindings>
        <jxb:bindings node="//xs:element[@name='VehicleObjects']/xs:complexType/xs:choice">
        <jxb:property name="VehicleObjectList"/>
        </jxb:bindings>
        </jxb:bindings>

        This would raise the "compiler was unable to honor this property customization."
        on the property bindings.
        I try declaring the choice in a group element , or putting the choice within a
        sequence under the complex type. I got always the same error from xjc.

        Show
        karl92 added a comment - Same behavior with the sample below and with jaxb ri version 2.1.3 and 2.1.4 Here is an extract of my sample schema : <xs:element name="VehicleObjects"> <xs:complexType> <xs:choice minOccurs="0" maxOccurs="unbounded"> <xs:element ref="CarObject"/> <xs:element ref="TruckObject"/> </xs:choice> </xs:complexType> </xs:element> Without property customization, xjc generates the following java source : @XmlRootElement(name = "VehicleObjects") public class VehicleObjects { @XmlElements( { @XmlElement(name = "CarObject", type = CarObject.class), @XmlElement(name = "TruckObject", type = TruckObject.class) } ) protected List<VehicleObject> carObjectsAndTruckObjects; I wanted to rename the ugly 'carObjectsAndTruckObjects' name into 'vehicleObjectList' by using the following external bindings : <jxb:bindings schemaLocation="myschema.xsd" node="/xs:schema"> <jxb:schemaBindings> <jxb:package name="com.sample.jaxb"/> </jxb:schemaBindings> <jxb:bindings node="//xs:element [@name='VehicleObjects'] /xs:complexType/xs:choice"> <jxb:property name="VehicleObjectList"/> </jxb:bindings> </jxb:bindings> This would raise the "compiler was unable to honor this property customization." on the property bindings. I try declaring the choice in a group element , or putting the choice within a sequence under the complex type. I got always the same error from xjc.
        Hide
        Pavel Bucek added a comment -

        adjusting priority

        Show
        Pavel Bucek added a comment - adjusting priority

          People

          • Assignee:
            jaxb-issues
            Reporter:
            ped
          • Votes:
            4 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: