jaxb
  1. jaxb
  2. JAXB-793

Multiple element definition not read correctly

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.1
    • Fix Version/s: not determined
    • Component/s: runtime
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

      Description

      Hi all,

      I have the following schema complex type:

      <complexType name="PolicyType">
      <complexContent>
      <restriction base="

      {http://www.w3.org/2001/XMLSchema}

      anyType">
      <sequence>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      Description" minOccurs="0"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      PolicyDefaults" minOccurs="0"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      CombinerParameters" minOccurs="0"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      Target"/>
      <choice maxOccurs="unbounded">
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      CombinerParameters" minOccurs="0"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      RuleCombinerParameters" minOccurs="0"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      VariableDefinition"/>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      Rule"/>
      </choice>
      <element ref="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      Obligations" minOccurs="0"/>
      </sequence>
      <attribute name="PolicyId" use="required" type="

      {http://www.w3.org/2001/XMLSchema}

      anyURI" />
      <attribute name="Version" type="

      {urn:oasis:names:tc:xacml:2.0:policy:schema:os}

      VersionType" default="1.0" />
      <attribute name="RuleCombiningAlgId" use="required" type="

      {http://www.w3.org/2001/XMLSchema}

      anyURI" />
      </restriction>
      </complexContent>
      </complexType>

      The corresponding JAXB class looks like:

      @XmlType(name = "PolicyType", propOrder =

      { "description", "policyDefaults", "combinerParameters", "target", "additionalInformation", "obligations" }

      )
      public class PolicyType implements Evaluatable, Serializable {
      private static final long serialVersionUID = 1L;
      @XmlElement(name = "Description")
      private String description;
      @XmlElement(name = "PolicyDefaults")
      private DefaultsType policyDefaults;
      @XmlElement(name = "combinerParameters")
      private CombinerParametersType combinerParameters;
      @XmlElement(name = "Target", required = true)
      private TargetType target;
      @XmlElements(

      { @XmlElement(name = "Rule", type = RuleType.class), @XmlElement(name = "VariableDefinition", type = VariableDefinitionType.class), @XmlElement(name = "RuleCombinerParameters", type = RuleCombinerParametersType.class), @XmlElement(name = "CombinerParameters", type = CombinerParametersType.class) }

      )
      private List<Object> additionalInformation;
      @XmlElement(name = "Obligations")
      private ObligationsType obligations;
      @XmlAttribute(name = "PolicyId", required = true)
      @XmlSchemaType(name = "anyURI")
      private String policyId;
      @XmlAttribute(name = "Version")
      private String version;
      @XmlAttribute(name = "RuleCombiningAlgId", required = true)
      @XmlJavaTypeAdapter(RuleCombiningAlgorithmJAXBTypeAdapter.class)
      @XmlSchemaType(name = "anyURI")
      private AbstractRuleCombiningAlgorithm ruleCombiningAlg;

      ...

      The thing I want to talk about is the CombinerParameters element. This element is defined twice at different places.
      Now when I unmarshal an XML that contains two CombinerParameters elements at the two places the unmarshalling is incorrect.
      The second CombinerParameters element is saved into the CombinerParameters element and the first one disappears.
      I think the unmarshalling saves both elements into this element and the second overrides the first.
      I think the behavior should be that the first is saved into the CombinerParameters field and the second into the
      additionalInformation (Choice).

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Iaroslav Savytskyi
            Reporter:
            fhuonder
          • Votes:
            2 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: