无法通过XJC生成枚举类

时间:2019-03-28 12:13:30

标签: java jaxb xjc cxf-xjc-plugin

我的XSD标签为:

<xs:complexType name="ifExpression">
        <xs:annotation>
            <xs:documentation>Boolean logic depending on expressions</xs:documentation>
        </xs:annotation>
        <xs:sequence>
            <xs:element name="variableName" type="xs:string"/>
            <xs:element name="operation">
                <xs:simpleType>
                    <xs:restriction base="xs:string">
                        <xs:enumeration value="eq"/>
                        <xs:enumeration value="ne"/>
                        <xs:enumeration value="gt"/>
                        <xs:enumeration value="lt"/>
                        <xs:enumeration value="ge"/>
                        <xs:enumeration value="le"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="value" type="tet:valueType"/>
        </xs:sequence>
    </xs:complexType>

我有一个绑定文件:

<jxb:bindings schemaLocation="Selector.xsd">
        <jxb:bindings node="//xsd:element[@name='ifExpression']/xsd:sequence/xsd:element[@name='operation']">
            <jxb:typesafeEnumClass name="Operation" />
        </jxb:bindings>
    </jxb:bindings>

我将其作为全局绑定:

<jxb:globalBindings generateIsSetMethod="true" enableJavaNamingConventions="true" underscoreBinding="asCharInWord" typesafeEnumMemberName="generateName" typesafeEnumBase="xsd:string" fixedAttributeAsConstantProperty="true" />

现在,当我运行mvn clean install时,出现以下错误:

com.sun.istack.SAXParseException2: compiler was unable to honor this enum customization. It is attached to a wrong place, or its inconsistent with other bindings.
    at com.sun.tools.xjc.ErrorReceiver.error (ErrorReceiver.java:86)
    at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error (ErrorReporter.java:84)
    at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check (UnusedCustomizationChecker.java:150)
.
.
.
com.sun.istack.SAXParseException2: (the above customization is attached to the following location in the schema)
    at com.sun.tools.xjc.ErrorReceiver.error (ErrorReceiver.java:86)
    at com.sun.tools.xjc.reader.xmlschema.ErrorReporter.error (ErrorReporter.java:84)
    at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check (UnusedCustomizationChecker.java:155)
    at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.check (UnusedCustomizationChecker.java:128)
    at com.sun.tools.xjc.reader.xmlschema.UnusedCustomizationChecker.elementDecl (UnusedCustomizationChecker.java:233)

只是想知道我在绑定文件的路径中做错了什么吗?还是我完全走错了道路?

0 个答案:

没有答案