JavaプロジェクトからISAN Restful APIを呼び出したいので、maven-jaxb2-pluginを使用してxsdファイルからJava Beanを生成しようとしています。ここでのXSDは以下のとおりです。XJC - コンパイラがこのクラスのカスタマイズを尊重することができませんでした
- http://www.isan.org/schema/v1.11/common/common.xsd
- http://www.isan.org/schema/v1.21/common/serial.xsd
- http://www.isan.org/schema/v1.11/common/version.xsd
- http://www.isan.org/ISAN/isan.xsd
- http://www.isan.org/schema/v1.11/common/title.xsd
- http://www.isan.org/schema/v1.11/common/externalid.xsd
- http://www.isan.org/schema/v1.11/common/participant.xsd
- http://www.isan.org/schema/v1.11/common/language.xsd
- http://www.isan.org/schema/v1.11/common/country.xsd
私は、論文のファイルをダウンロードし、私のsrc/main/resourcesフォルダにそれらをコピーしてカタログを定義しました。 私はプロジェクトをビルドすると2種類が同じ名前持っているので、私はエラーを取得:
org.xml.sax.SAXParseExceptionpublicId: http://www.isan.org/schema/v1.11/common/language; systemId: http://www.isan.org/schema/v1.11/common/language.xsd; lineNumber: 39; columnNumber: 48; A class/interface with the same name "org.isan.CodingSystemType" is already in use. Use a class customization to resolve this conflict.
org.xml.sax.SAXParseExceptionpublicId: http://www.isan.org/schema/v1.11/common/country; systemId: http://www.isan.org/schema/v1.11/common/country.xsd; lineNumber: 39; columnNumber: 48; (Relevant to above error) another "CodingSystemType" is generated from here.
正しいです:
<xs:simpleType name="CodingSystemType">
<xs:restriction base="xs:string">
<xs:enumeration value="ISO639_2"/>
<xs:enumeration value="RFC3066"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="CodingSystemType">
<xs:restriction base="xs:string">
<xs:enumeration value="ISO3166_1"/>
</xs:restriction>
</xs:simpleType>
:language.xsdとcountry.xsd両方がCodingSystemType名前付きの型を定義します
提案したように、私はcountry.xsd型のクラスカスタマイズを使用しようとしました。私はのpom.xmlにこのバインディングを追加しました:
<bindings>
<binding>
<url>http://www.isan.org/schema/v1.11/common/country.xjb</url>
</binding>
</bindings>
XJCファイル:今
<bindings version="2.0" xmlns="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:annox="http://annox.dev.java.net"
xmlns:namespace="http://jaxb2-commons.dev.java.net/namespace-prefix">
<bindings schemaLocation="http://www.isan.org/schema/v1.11/common/country.xsd">
<bindings node="//xs:simpleType[@name='CodingSystemType']">
<class name="CountryCodingSystemType" />
</bindings>
</bindings>
</bindings>
、私は私がに対処することはできません別のエラーを取得:
[ERROR] Error while parsing schema(s).Location [ http://www.isan.org/schema/v1.11/common/country.xjb{7,58}].
com.sun.istack.SAXParseException2; systemId: http://www.isan.org/schema/v1.11/common/country.xjb; lineNumber: 7; columnNumber: 58; compiler was unable to honor this class customization. It is attached to a wrong place, or its inconsistent with other bindings.
[ERROR] Error while parsing schema(s).Location [ http://www.isan.org/schema/v1.11/common/country.xsd{39,48}].
com.sun.istack.SAXParseException2; systemId: http://www.isan.org/schema/v1.11/common/country.xsd; lineNumber: 39; columnNumber: 48; (the above customization is attached to the following location in the schema)
あなたの問題に関連しているかどうかは不明ですが、通常はパッケージをクラス名のバインディングに含めないでください: 'name =" CountryCodingSystemType "'。 – Rob
パッケージがないと同じ問題が発生します。しかし、あなたはそれが正しくないと言って私の投稿を編集しました。 – jaudo