根据链接
如果 typesafeEnumBase 设置为 xsd:string,这将是一种全局方式来指定所有直接或间接从 xsd:string 派生并具有枚举方面的简单类型定义应默认绑定到类型安全枚举。如果 typesafeEnumBase 设置为 空字符串 "",则默认情况下不会将简单类型定义绑定到类型安全枚举类。typesafeEnumBase 的值可以是除 xsd:boolean和两种二进制类型之外的任何原子简单类型定义。
所以我设置binding.xjb
了以下内容:
<jxb:globalBindings typesafeEnumBase=""/>
并且在运行时jaxb2-maven-plugin
出现以下异常:
lineNumber: 5; columnNumber: 46; cvc-minLength-valid: Value '' with length = '0' is not facet-valid with respect to minLength '1' for type '#AnonType_typesafeEnumBaseglobalBindings'.
...
lineNumber: 5; columnNumber: 46; cvc-attribute.3: The value '' of attribute 'typesafeEnumBase' on element 'jxb:globalBindings' is not valid with respect to its type, 'null'.
据我了解,即使文档如此说明,我也无法将空字符串设置""
为typesafeEnumBase
。文档还提到它不能是xsd:boolean
.
我想要的只是将以下内容转换String
为enum
<xs:simpleType name="phraseID">
<xs:restriction base="escapedStringUserType">
<xs:enumeration value="NOT_SPECIFIED"/>
<xs:enumeration value="X000-9999"/>
<xs:enumeration value="X000-9998"/>
</xs:restriction>
</xs:simpleType>
一个相关的 SO 问题在这里,但由于我无法设置空字符串""
或将xsd:boolean
值设置typesafeEnumBase
为对我来说没有任何答案(都尝试过)。