mojohaus / jaxb2-maven-plugin

JAXB2 Maven Plugin
https://www.mojohaus.org/jaxb2-maven-plugin/
Apache License 2.0
106 stars 77 forks source link

jaxb2 plugin fails to generate enum class if elements are the same but using uppercase and lowercase as a differentiator #103

Closed dfcoffin closed 6 years ago

dfcoffin commented 6 years ago

I am attempting to generate an enumeration class using jaxb2-maven-plugin from the NIST SI prefix definitions https://physics.nist.gov/cuu/Units/prefixes.html as defined by the attached .xsd file:

SiScaleCodeType.txt

The NIST definition contains multiple values of the same letter (i.e., "M" and "m") only differentiated by the case of the label. However, the jaxb2-maven-plugin only emits upperCase values, which causes it to terminate generation of the Java enum class when it encounters the second occurance of the same value without any error messages. Since this is a National standard, I am unable to redefine the values in the XSD to circumvent this issue.

lennartj commented 6 years ago

This is clearly a bug - but it seems to stem from the underlying XJC tool. Running the xjc command manually, the XSD snippet below generates code when the lowercase m value is commented out, and no code when it is commented in.

Hence - this is a bug, but in the XJC. I ran only with JDK 8 and JDK 10, but it seems fair to say that this is a bug within the JDK tooling. Please refer to the OpenJDK bug tracker to place a fix or bug ticket.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="urn:X-fsgim:fsgim" targetNamespace="urn:X-fsgim:fsgim">
    <xs:annotation>
        <xs:documentation>The FSGIMWeather model describes an abstract representation of weather information that may be
            used by or exchanged with the facility. It includes weather information and forecasts that may be received
            from outside providers, and information generated through observations (measurements) performed at the
            facility. The weather model also includes weather phenomena such as wind, rain, and storms.
        </xs:documentation>
    </xs:annotation>
    <xs:simpleType name="MD_CharacterSetCode">
        <xs:restriction base="xs:string">
            <xs:enumeration value="M">
                <xs:annotation>
                    <xs:documentation>mega (106)</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
            <!-- xs:enumeration value="m">
                <xs:annotation>
                    <xs:documentation>mega (106)</xs:documentation>
                </xs:annotation>
            </xs:enumeration -->
            <xs:enumeration value="eucJP">
                <xs:annotation>
                    <xs:documentation>japanese code set used on UNIX based machines.</xs:documentation>
                </xs:annotation>
            </xs:enumeration>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>