JAXB XJC 两个声明导致冲突。定制绑定无法兑现

2024-02-24

我想从此架构文件生成 JAXB 类:http://www.taxonx.org/schema/v1/taxonx1.xsd http://www.taxonx.org/schema/v1/taxonx1.xsd

我使用自定义绑定解决了由导入的 mods-3-1.xsd 引起的几个命名冲突,如下所示:

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

  <jxb:bindings schemaLocation="http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
    <jxb:bindings
        node="//xsd:complexType[@name='relatedItemType']/xsd:attribute[@name='type']">
        <jxb:property name="type2" />
    </jxb:bindings>

    <jxb:bindings
        node="//xsd:attributeGroup[@name='language']/xsd:attribute[@name='lang']">
        <jxb:property name="lang2" />
    </jxb:bindings>

    <jxb:bindings
        node="//xsd:complexType[@name='titleInfoType']/xsd:complexContent/xsd:extension/xsd:attribute[@name='type']">
        <jxb:property name="type3" />
    </jxb:bindings>

    <jxb:bindings
        node="//xsd:complexType[@name='nameType']/xsd:attribute[@name='type']">
        <jxb:property name="type4" />
    </jxb:bindings>

    <jxb:bindings
        node="//xsd:complexType[@name='unstructuredText']/xsd:simpleContent/xsd:extension/xsd:attribute[@name='type']">
        <jxb:property name="type5" />
    </jxb:bindings>
  </jxb:bindings>
</jxb:bindings>

当我想生成类时,我仍然收到以下错误:

parsing a schema...
compiling a schema...
[ERROR] Two declarations cause a collision in the ObjectFactory class.
line 468 of http://digir.net/schema/conceptual/darwin/manis/1.21/darwin2.xsd

[ERROR] (Related to above error) This is the other declaration.
line 326 of http://digir.sourceforge.net/schema/protocol/2003/1.0/digir.xsd

Failed to produce code.

当我添加另一个自定义绑定时..

<jxb:bindings schemaLocation="http://digir.net/schema/conceptual/darwin/manis/1.21/darwin2.xsd">
    <jxb:bindings
        node="//xsd:element[@name='requiredList' and @substitutionGroup='digir:requiredList']">
        <jxb:property name="requiredList2" />
    </jxb:bindings>
</jxb:bindings>

我收到另一个错误:

parsing a schema...
[ERROR] compiler was unable to honor this property customization. It is attached to a     
wrong place, or its inconsistent with other bindings.
line 34 of file:/C:/git/charaparser%20-%20Copy/resources/io/darwinCore/mods-3-1-
bindings.xml

[ERROR] (the above customization is attached to the following location in the schema)
line 468 of http://digir.net/schema/conceptual/darwin/manis/1.21/darwin2.xsd

Failed to parse a schema.

有什么想法如何解决这个问题吗?


一个非常好的答案在这里:

http://blog.lunatech.com/2008/10/17/geneating-kml-restful-clients http://web.archive.org/web/20150510110454/http://blog.lunatech.com/2008/10/17/generating-kml-restful-clients

简而言之,使用<jaxb:factoryMethod name="RequiredList2"/>定制。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JAXB XJC 两个声明导致冲突。定制绑定无法兑现 的相关文章

随机推荐