I'd like to call ISAN Restful API from my Java project, so I'm trying to generate java beans from xsd files using maven-jaxb2-plugin. Here are the xsds:
- 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
I downloaded theses files and copied them into my src/main/resources folder. Here is my plugin configuration from pom.xml:
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
</configuration>
<executions>
<execution>
<id>isan</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generatePackage>org.isan</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/isan</generateDirectory>
</configuration>
</execution>
</executions>
</plugin>
Now the plugin is telling me that some types are defined multiple times. For example :
03/11/2016 16:42:53 UTC+1: [ERROR] Error while parsing schema(s).Location [ file:/D:/isan/isan/src/main/resources/common.xsd{51,37}]. 'DurationType' is already defined 03/11/2016 16:42:53 UTC+1: [ERROR] Error while parsing schema(s).Location [ http://www.isan.org/schema/v1.11/common/common.xsd{46,38}]. (related to above error) the first definition appears here
I understand this is because each type is defined in my local file and in the remote file. One solution seem to be using catalogs (https://github.com/highsource/maven-jaxb2-plugin/wiki/Using-Catalogs), but it doesn't seem to work.
I added this catalog in "src/main/resources:"
PUBLIC "http://www.isan.org/schema/v1.11/common/common.xsd" "./common.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/country.xsd" "./country.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/externalid.xsd" "./externalid.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/isan.xsd" "./isan.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/language.xsd" "./language.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/participant.xsd" "./participant.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/serial.xsd" "./serial.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/title.xsd" "./title.xsd"
PUBLIC "http://www.isan.org/schema/v1.11/common/version.xsd" "./version.xsd"
REWRITE_SYSTEM "http://www.isan.org" "isan"
and modified the plugin configuration:
<configuration>
<strict>false</strict>
<catalog>src/main/resources/catalog.cat</catalog>
<generatePackage>org.isan</generatePackage>
<generateDirectory>${project.build.directory}/generated-sources/isan</generateDirectory>
</configuration>
I'm still getting the same errors