Java Can';不要在单个xsd元素上使用jaxb绑定

Java Can';不要在单个xsd元素上使用jaxb绑定,java,jaxb,xjc,jaxb2-maven-plugin,Java,Jaxb,Xjc,Jaxb2 Maven Plugin,我使用jaxb从xsd文件生成java源代码 我希望能够在每个元素的基础上指定在哪些包中生成源,但是每当我生成源时,就会出现以下错误: [ERROR] ****/src/main/xjb/common.xjb[8,24] com.sun.istack.SAXParseException2: compiler was unable to honor this schemaBinding customization. It is attached to a wrong place, or its i

我使用jaxb从xsd文件生成java源代码

我希望能够在每个元素的基础上指定在哪些包中生成源,但是每当我生成源时,就会出现以下错误:

[ERROR] ****/src/main/xjb/common.xjb[8,24]
com.sun.istack.SAXParseException2: compiler was unable to honor this schemaBinding customization. It is attached to a wrong place, or its inconsistent with other bindings.
我的绑定文件common.xjb正在尝试将名为(属性值)“api”的元素放置在包“com.myxml.common.api”中:

<jxb:bindings version="1.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <jxb:bindings schemaLocation="../xsd/common/common.xsd" node="/xs:schema">

        <jxb:bindings node="//xs:element[@name='api']">
            <jxb:schemaBindings>
                <jxb:package name="com.myxml.common.api" />
            </jxb:schemaBindings>
        </jxb:bindings>

    </jxb:bindings>

</jxb:bindings>

我的xsd文件common.xsd是:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.1" xml:lang="en">

    <xs:element name='api'>
        <xs:complexType>
            <xs:simpleContent>
                <xs:extension base="xs:string" />
            </xs:simpleContent>
        </xs:complexType>
    </xs:element>

</xs:schema>

我正在使用以下Maven插件让一切正常进行:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxb2-maven-plugin</artifactId>
    <version>1.5</version>

    <executions>
        <execution>
            <id>schema00-generate</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>xjc</goal>
            </goals>
            <configuration>
                <schemaFiles>common/common.xsd</schemaFiles>
                <bindingFiles>common.xjb</bindingFiles>
                <bindingDirectory>${project.basedir}/src/main/xjb</bindingDirectory>
            </configuration>
        </execution>
    </executions>
</plugin>

org.codehaus.mojo
jaxb2 maven插件
1.5
schema00生成
生成源
xjc
common/common.xsd
common.xjb
${project.basedir}/src/main/xjb

为什么会出现此错误,如何解决?我知道在这个阶段没有使用任何其他绑定。

来自同一名称空间的元素不能映射到不同的包,因此不能为顶层以外的任何内容定义包