1

我正在尝试从 xsd 生成类,但在尝试自定义简单类型时出现以下异常:

    com.sun.istack.SAXParseException2: A type safe enum customization is specified to a simple type that cannot be mapped to a type safe enum.

抛出异常的简单类型的声明如下:

    <xs:simpleType name="BroadcastAlertsItem">
    <xs:annotation>
        <xs:appinfo>
        reserved (0)
        broadcastAlertsAccepted (1)
        broadcastAlertsNotAccepted (2)
     </xs:appinfo>
    </xs:annotation>
    <xs:union>
        <xs:simpleType>
            <xs:restriction base="xs:unsignedInt">
                <xs:minInclusive value="0"/>
                <xs:maxInclusive value="2"/>
            </xs:restriction>
        </xs:simpleType>
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:enumeration value="reserved"/>
                <xs:enumeration value="broadcastAlertsAccepted"/>
                <xs:enumeration value="broadcastAlertsNotAccepted"/>
            </xs:restriction>
        </xs:simpleType>
    </xs:union>
</xs:simpleType>

这是绑定自定义文件中的绑定:

    <jaxb:bindings node="//xs:simpleType[@name='BroadcastAlertsItem']">
        <jaxb:typesafeEnumBase name="BroadcastAlertsItem">
            <jaxb:typesafeEnumMember name="reserved"/>
            <jaxb:typesafeEnumMember name="broadcastAlertsAccepted"/>
            <jaxb:typesafeEnumMember name="broadcastAlertsNotAccepted"/>
        </jaxb:typesafeEnumBase>
    </jaxb:bindings>

如您所想,我已经尝试了更多方法来实现这一目标:(

有谁知道是否有一种方法可以在不修改 xsd 文件的情况下绑定该简单类型?

非常感谢。

4

0 回答 0