eclipse-ee4j / jaxb-ri

Jaxb RI
https://eclipse-ee4j.github.io/jaxb-ri/
BSD 3-Clause "New" or "Revised" License
202 stars 110 forks source link

Nested xsd unions generate lists in java objects #1130

Open Tomas-Kraus opened 7 years ago

Tomas-Kraus commented 7 years ago

I have the following type in my xsd:

This is formatted representation of a date, which may be specified as a date, date/time, year, or year/month. I would expect it to be translated into a String when generating the Java objects using xjc but it is translated into a List instead. After having run a few tests, I think it is because the type oa:DateTimeType contained in the union is also a union: QDT000000 QDT Month_ Date. Type 1.0 A particular point in the progression of time together with the relevant supplementary information. Provides the XML Schema simpleType that allows either just the Date or the Date and Time to be provided in the elements that are based on this type and/or types that use this as their base. Date Month Is this behaviour expected? What should I do to obtain a String? A solution that works is to replace the member oa:DateTimeType in FormattedDateTimeType directly by its own members but I don't know if it is a good practice. Many thanks
Tomas-Kraus commented 6 years ago
Yoann-lwk commented 2 years ago

Hi,

I'm getting the same issue with the type NilReasonType in the xsd file http://schemas.opengis.net/gml/3.2.1/basicTypes.xsd <simpleType name="NilReasonType"> <annotation>...</annotation> <union memberTypes="gml:NilReasonEnumeration anyURI"/> </simpleType> <simpleType name="NilReasonEnumeration"> <union> <simpleType> <restriction base="string"> <enumeration value="inapplicable"/> <enumeration value="missing"/> <enumeration value="template"/> <enumeration value="unknown"/> <enumeration value="withheld"/> </restriction> </simpleType> <simpleType> <restriction base="string"> <pattern value="other:\w{2,}"/> </restriction> </simpleType> </union> </simpleType>

As mentionned by Tomas-Kraus, I would expect it to be translated into a String but JaxB translate it as list. Do I understand uncorrectly the XSD file definition or does JaxB translate it as a list because of:

Thank to give some information on this behaviour.