[英]How do I correct XSD for JAXB generator?
I prepared complexType
, an enum with two attributes:我准备了complexType
,一个具有两个属性的枚举:
<xsd:complexType name="Action">
<xsd:simpleContent>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="A"/>
<xsd:enumeration value="B"/>
<xsd:enumeration value="C"/>
</xsd:restriction>
</xsd:simpleContent>
<xsd:attribute name="attrA" type="xsd:string" />
<xsd:attribute name="attrB" type="xsd:string" />
</xsd:complexType>
The problem is, JAXB
prevents me from creating Java classes for that code, I get the following error:问题是, JAXB
阻止我为该代码创建 Java 类,我收到以下错误:
When is used, the base type must be a complexType whose content type is simple, or, only if restriction is specified, a complex type with mixed content and emptiable particle, or, only if extension is specified, a simple type.使用时,基类型必须是内容类型为简单的complexType,或者只有在指定了限制条件的情况下,才可以是混合内容和可空粒子的复杂类型,或者只有在指定了扩展名的情况下,才可以是简单类型。 'string' satisfies none of these conditions. 'string' 不满足这些条件。
Online validator showed me my code is corrent one.在线验证器向我展示了我的代码是正确的。 How do I change this to make xjc
convert my schema definition?如何更改它以使xjc
转换我的模式定义?
Your xsd is not well formed.您的 xsd 格式不正确。 Try below complexType
试试下面的complexType
<xs:complexType name="Action">
<xs:simpleContent>
<xs:extension base="ActionValue">
<xs:attribute name="attrA" type="xs:string" />
<xs:attribute name="attrB" type="xs:string" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="ActionValue">
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />
<xs:enumeration value="C" />
</xs:restriction>
</xs:simpleType>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.