jaxb
  1. jaxb
  2. JAXB-518

When XMLSchema is generated from Java with schemagen command, information on nillable of Java is not correctly reflected in XMLSchema.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.6
    • Fix Version/s: 2.1.13
    • Component/s: schemagen
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      518

      Description

      When nillable is not specified for @XMLElement of Java, nillable ="true" is
      specified for XMLSchema generated with the schemagen command.

      Accoding to javadoc of javax.xml.bind.annotation.XmlElement.nillable, its
      default value is false.

      Moreover, when XMLSchema is the following, nillable is not actually specified
      for @XmlElement of the Java generated from the XMLSchema by xjc command.
      ・When you specify nillable ="false" for element of XMLSchema, or
      ・When you do not specify nillable for element of XMLSchema.

      Therefore, when Java is generated from XMLSchema of the above-mentioned
      condition, and XMLSchema is generated from that Java, the nillable attribute
      information of XMLSchema is different from former XMLSchema.

      (example)
      ----------------formar SCHEMA------------------
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <xs:schema version="1.0" targetNamespace="http://servlet_endpoint/"
      xmlns:tns="http://servlet_endpoint/" xmlns:ns1="http://jaxb.dev.java.net/array"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <xs:import namespace="http://jaxb.dev.java.net/array"
      schemaLocation="MultiTypeArrayService_schema2.xsd"/>

      <xs:element name="paramInInteger" type="tns:paramInInteger"/>

      <xs:element name="paramInIntegerResponse" type="tns:paramInIntegerResponse"/>

      <xs:complexType name="paramInInteger">
      <xs:sequence>
      <xs:element name="arg0" type="ns1:intArray" minOccurs="0"
      maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>

      <xs:complexType name="paramInIntegerResponse">
      <xs:sequence>
      <xs:element name="return" type="xs:int"/>
      </xs:sequence>
      </xs:complexType>

      </xs:schema>

      ----------------generated Java------------------
      servlet_endpoint/ParamInInteger.java

      package servlet_endpoint;

      import java.util.ArrayList;
      import java.util.List;
      import javax.xml.bind.annotation.XmlAccessType;
      import javax.xml.bind.annotation.XmlAccessorType;
      import javax.xml.bind.annotation.XmlType;
      import net.java.dev.jaxb.array.IntArray;

      @XmlAccessorType(XmlAccessType.FIELD)
      @XmlType(name = "paramInInteger", propOrder = {
      "arg0"
      })
      public class ParamInInteger {

      protected List<IntArray> arg0;

      public List<IntArray> getArg0() {
      if (arg0 == null)

      { arg0 = new ArrayList<IntArray>(); }

      return this.arg0;
      }

      }
      ----------------generated SCHEMA------------------
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
      <xs:schema version="1.0" targetNamespace="http://servlet_endpoint/"
      xmlns:tns="http://servlet_endpoint/" xmlns:ns1="http://jaxb.dev.java.net/array"
      xmlns:xs="http://www.w3.org/2001/XMLSchema">

      <xs:import namespace="http://jaxb.dev.java.net/array"
      schemaLocation="MultiTypeArraySchema2.xsd"/>

      <xs:element name="paramInInteger" nillable="true" type="tns:paramInInteger"/>

      <xs:element name="paramInIntegerResponse" nillable="true"
      type="tns:paramInIntegerResponse"/>

      <xs:complexType name="paramInIntegerResponse">
      <xs:sequence>
      <xs:element name="return" type="xs:int"/>
      </xs:sequence>
      </xs:complexType>

      <xs:complexType name="paramInInteger">
      <xs:sequence>
      <xs:element name="arg0" type="ns1:intArray" nillable="true" minOccurs="0"
      maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>
      ------------------------------------------

      How about you though it thinks this to be an acute problem?

        Activity

        Hide
        zhaohuifeng added a comment -

        I'm seeing the same issue with javax.xml.bind.JAXBContext.generateSchema
        (SchemaOutputResolver). With the nillable is set to true, the generated WSDL is
        not qualified as doc-lit-wrapper style per JAX-WS spec.

        Show
        zhaohuifeng added a comment - I'm seeing the same issue with javax.xml.bind.JAXBContext.generateSchema (SchemaOutputResolver). With the nillable is set to true, the generated WSDL is not qualified as doc-lit-wrapper style per JAX-WS spec.
        Hide
        Martin Grebac added a comment -

        I do have a fix in trunk, that's easy to fix in JAXB. However, this should most
        certainly break JAX-WS compatibility tests - since JAX-WS uses schemagen with
        their web services from Java. So I need to contact JAX-WS guys on how to proceed
        here. Might happen we will not be allowed to fix this. Stay tuned.

        Show
        Martin Grebac added a comment - I do have a fix in trunk, that's easy to fix in JAXB. However, this should most certainly break JAX-WS compatibility tests - since JAX-WS uses schemagen with their web services from Java. So I need to contact JAX-WS guys on how to proceed here. Might happen we will not be allowed to fix this. Stay tuned.
        Hide
        Martin Grebac added a comment -

        Forgot to reassign to myself.

        Show
        Martin Grebac added a comment - Forgot to reassign to myself.
        Hide
        Martin Grebac added a comment -

        Unfortunately this would break backward compatibility for both JAXB and JAX-WS,
        so marking as wontfix. You can easily workaround it by specifying XmlElement
        annotation on the collection property, with or without including the nillability
        attribute.

        Show
        Martin Grebac added a comment - Unfortunately this would break backward compatibility for both JAXB and JAX-WS, so marking as wontfix. You can easily workaround it by specifying XmlElement annotation on the collection property, with or without including the nillability attribute.
        Hide
        gfuser9999 added a comment -

        How do this workaround work for parameter

        void test1Darray(@XmlElement(nillable=false) int[]array) {
        }
        

        It seems that the generated XSD always have nillable true
        and then later code using these XSD will not generate
        the right stuff. So what's the workaround for these.

        Show
        gfuser9999 added a comment - How do this workaround work for parameter void test1Darray(@XmlElement(nillable= false ) int []array) { } It seems that the generated XSD always have nillable true and then later code using these XSD will not generate the right stuff. So what's the workaround for these.

          People

          • Assignee:
            Martin Grebac
            Reporter:
            taniguti
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: