Unsupported binding namespace exception for vendor specific namespace - xsd

I have a Vendor.xsd, where the namespace definition is referencing a vendor specific namespace http://vendor.com/xjc-plugins. A snippet is given below:
...
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:common="http://annox.dev.java.net"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:vendor="http://vendor.com/xjc-plugins"
elementFormDefault="qualified"
jaxb:extensionBindingPrefixes="vendor common"
jaxb:version="2.0">
...
xs:complexType name="VendorType">
<xs:annotation>
<xs:appinfo>
<vendor:package>vendor.package</vendor:package>
</xs:appinfo>
</xs:annotation>
...
When I try to generate jaxbs by using either xjc from command line or maven-jaxb22-plugin the following exception occurs:
Unsupported binding namespace "http://vendor.com/xjc-plugins". Perhaps you meant "http://annox.dev.java.net"?
The maven plugin I am using is given here:
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb22-plugin</artifactId>
<version>0.13.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>Vendor.xsd</include>
</schemaIncludes>
<generatePackage>com.vendor.model</generatePackage>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>1.0.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>1.11.1</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-tools</artifactId>
<version>1.11.1</version>
</plugin>
</plugins>
</configuration>
</execution>
</executions>
</plugin>
Any ideas welcome ?

You do not seem to include your XJC plugin in plugins section of the maven-jaxb2-plugin configuration. Binding namespace must be acknowledged by some plugin. You only include jaxb2-basics but not the plugin which would acknowledge http://vendor.com/xjc-plugins.

Related

Generate Java Classes from XSD with default package name and XSD namespace

I have 2 sets of XSDs, One for Inbound operations and other for outbound operations. Both XSD sets have similar namespace but since are from different sources need to be maintained seperately in the same codeset. Each XSD set has deeply nested classes and generates roughly 650 classes.
I am using a Maven JAXB plugin to generate Java classes.
If I specify an <outputDirectory>, the file generation fails because of namespace collision between Outbound and Inbound operation. If I specify <packageName>, all classes are generated in the same package which results in namespace collision within Inbound operations.
Is there a way in which Maven will follow the package name provided by XSD namespace and prefix the package name with 'inbound' or 'outbound' to seperate the resulting package names. For e.g the packages create by XSD is
com.example.operation
com.example.operation.v1
Can it be modified to
inbound.com.example.operation
inbound.com.example.operation.v1
My Maven pom.xml file
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<groupId>com.example</groupId>
<modelVersion>4.0.0</modelVersion>
<artifactId>sample-integration-model</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>sample-integration-model</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>xjc-outbound</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<laxSchemaValidation>true</laxSchemaValidation>
<outputDirectory>target/jaxb2/outbound</outputDirectory>
<sources>
<source>src/main/xsd/OutboundXsd/RequestMessagesDictionary</source>
<source>src/main/xsd/OutboundXsd/ResponseMessagesDictionary</source>
</sources>
</configuration>
</execution>
<execution>
<id>xjc-inbound</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<laxSchemaValidation>true</laxSchemaValidation>
<outputDirectory>target/jaxb2/inbound</outputDirectory>
<sources>
<source>src/main/xsd/InboundXsd/RequestMessagesDictionary</source>
<source>src/main/xsd/InboundXsd/ResponseMessagesDictionary</source>
</sources>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
You can tell Maven to set the generated classes in a given package.
Use <generatePackage>desired.package</generatePackage> inside the execution tag.
It is well documented here.

JAXB2 maven plugin in eclipse shows error

I'm using JDK 1.6 (due to dependencies) and to generate classes from xsd, I have added maven-jaxb2 plugin as shown below in pom.xml.
But the eclipse (Kepler) complains as below.
Error parsing the command line [[-Xsimplify, -episode,
D:\test\workspace\sample\target\generated-sources\xjc\META-INF\sun-jaxb.episode]]
(org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.8.1:generate:jaxb-test:generate-sources)
pom.xml
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.9.0</version>
<executions>
<execution>
<id>jaxb-test</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>sample.xsd</include>
</schemaIncludes>
<xjbSources>
<xjbSource>bindings.xjb</xjbSource>
</xjbSources>
</configuration>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-Xsimplify</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.0</version>
</plugin>
</plugins>
</configuration>
</plugin>
</plugins>
Try to upgrade to maven-jaxb2-plugin 0.13.1, and jaxb2-basics 0.11.0.
The versions you have now are very old already.

JAXB 2 Maven plugin - use of episode - general project for xsd

I want to have a project A with some common used XML schema files and some java classes dependent on the generated classes (generated from jaxb), using namespace a and package a, and I want to have a project B dependent on project A.
in project B i want to have a XML schema file using some XML types from project A, project b has namespace b, then JAXB needs to generate java classes from schema b into the package b.
I know that episodes and catalogs might help, but i can not prevent jaxb to create the java classes comming from schema a twice in project b.
here is my maven configuration:
project A:
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<schemaIncludes>
<include>wsdl/WebServiceBaseRequestResponse.xsd</include>
</schemaIncludes>
<generatePackage>a</generatePackage>
<episode>true</episode>
</configuration>
</plugin>
</plugins>
</build>
Project B :
<!-- Used to pull XSD files from the JAR -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-xsd-files</id>
<phase>initialize</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>a</groupId>
<artifactId>a-xsd</artifactId>
<version>${project.version}</version>
<type>jar</type>
</artifactItem>
</artifactItems>
<includes>wsdl/*.xsd</includes>
<outputDirectory>${project.basedir}/target/xsd-includes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<configuration>
<extension>true</extension>
<episodes>
<episode>
<groupId>a</groupId>
<artifactId>sca-xsd</artifactId>
<version>${project.version}</version>
</episode>
</episodes>
<episode>false</episode>
<schemaIncludes>
<include>wsdl/b.xsd</include>
</schemaIncludes>
<generatePackage>b</generatePackage>
</configuration>
</plugin>
b.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema version="1" targetNamespace="a"
xmlns:tns="a" xmlns:com="b"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="a" schemaLocation="..relPathTo/target/xsd-includes/a.xsd>
<xs:element name="addShipmentOrderResult">
<xs:annotation>
<xs:documentation>
Result object for addShipmentOrder.
</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="com:baseResult">
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:element>
</xs:schema>
In this way you're not using the episodes, because you unpack the xsd within B project, so regenerates the classes from A project.
You should using the following configuration
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-Xannotate</arg>
<arg>-Xnamespace-prefix</arg>
<arg>-nv</arg>
</args>
<extension>true</extension>
<forceRegenerate>true</forceRegenerate>
<schemas>
<schema>
<fileset>
<directory>${basedir}/src/main/resources/schema/project/b</directory>
<includes>
<include>*.xsd</include>
</includes>
</fileset>
</schema>
<schema>
<dependencyResource>
<groupId>com.project.a</groupId>
<artifactId>artifact.a</artifactId>
<resource>schema/a.xsd</resource>
</dependencyResource>
</schema>
</schemas>
<episodes>
<episode>
<groupId>com.project.a</groupId>
<artifactId>artifact.a</artifactId>
</episode>
</episodes>
<debug>true</debug>
<verbose>true</verbose>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.2</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.1</version>
</plugin>
</plugins>
</configuration>
</plugin>
Remember to add as dependency the project A.

Not able to generate annotation through maven jaxb plugin

I am trying to add javax.persistence.Id as an annotation to a filed and generate as Java objects through Maven JAXB plugin. However I run into class not found exception for javax.persistence.id I did make sure that the javax.persistence is included in the maven dependency and I see maven pulling it as dependency but when I run through jaxb plugin it won't work.
Here is my XML <xsd:complexType name="MyTable">
<xsd:sequence>
<xsd:element name="id" type="xsd:int"/>
</xsd:sequence>
</xsd:complexType>
Here is my binding.xjb file
<jaxb:bindings version="2.1"
xmlns:jaxb="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" jaxb:extensionBindingPrefixes="annox">
<jaxb:bindings schemaLocation="mytable.xsd">
<jaxb:bindings node="xs:complexType[#name='MyTable']/xs:sequence/xs:element[#name='id']">
<annox:annotate target="field">
<annox:annotate annox:class="javax.persistence.Id"/>
</annox:annotate>
</jaxb:bindings>
</jaxb:bindings>
Here is my relevant Pom.xml
<dependencies>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.9</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.4</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<configuration>
<forceRegenerate>true</forceRegenerate>
<schemaDirectory>myschema</schemaDirectory>
<bindingIncludes>
<include>binding.xjb</include>
</bindingIncludes>
<extension>true</extension>
<args>
<arg>-Xvalue-constructor</arg>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xcopyable</arg>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin> <groupId>org.jvnet.jaxb2_commons</groupId>
jaxb2-basics 0.6.4
org.jvnet.jaxb2_commons
jaxb2-basics-annotate 0.6.4
org.jvnet.jaxb2_commons
jaxb2-value-constructor
3.0
</plugins>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<versionRange>[0.7.4,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
However when I run Maven-->Generate-Sources I get this error
Caused by: org.jvnet.annox.parser.AnnotationElementParseException: Could not parse the annotation element.
at org.jvnet.annox.parser.XAnnotationParser.parse(XAnnotationParser.java:90)
at org.jvnet.jaxb2_commons.plugin.annotate.AnnotatePlugin.annotate(AnnotatePlugin.java:387)
... 31 more
Caused by: org.jvnet.annox.annotation.AnnotationClassNotFoundException: Annotation class [javax.persistence.Id] could not be found.
... 33 more
Caused by: java.lang.ClassNotFoundException: javax.persistence.Id
If I simply add #Id annotation to any java class in the project then I can add and I see javax.persistence.Id getting imported with no problem. What is going wrong when I use maven & binding.xjb? Am I not defining the annotation properly? Many thanks!
I guess it's also the same problem that I had: you added javax.persistence as a Maven dependency, but not as a dependency to your JAXB plugin:
Add something like this (if you're using Hibernate):
</project>
...
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<executions>
...
</executions>
<configuration>
...
</configuration>
<dependencies>
<!-- Hibernate Persistence Annotations -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>${hibernate-jpa-2.0-api.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
</project>
I had a similar issue and was able to solve it with that. In the following example please note that I'm putting the annotations into the XSD and not into the XJB file but the Maven configuration should be similar.
Here's my XSD:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.1"
elementFormDefault="qualified" targetNamespace="http://www.gl-group.com/ewelding/schemas"
xmlns:ew="http://www.companyname.com/project/schemas"
xmlns:xmime="http://www.w3.org/2005/05/xmlmime" jaxb:extensionBindingPrefixes="annox"
xmlns:annox="http://annox.dev.java.net"
xmlns:ja="http://annox.dev.java.net/javax.xml.bind.annotation"
xmlns:jpa="http://annox.dev.java.net/javax.persistence"
xmlns:solrj="http://annox.dev.java.net/org.apache.solr.client.solrj.beans"
xmlns:jackson="http://annox.dev.java.net/com.fasterxml.jackson.annotation">
...
<xs:element name="Certificate">
<xs:annotation>
<xs:appinfo>
<annox:annotate>
<ja:XmlAccessorType value="NONE"/>
<jpa:Entity name="Certificate"/>
<solrj:Field value="testByOrderOf"/>
<jackson:JsonFormat shape="STRING" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT"/>
</annox:annotate>
</xs:appinfo>
</xs:annotation>
...
<xs:element ref="ew:dateOfBirth">
<xs:annotation>
<xs:appinfo>
<annox:annotate target="field">
<solrj:Field value="dateOfBirth"/>
<jackson:JsonFormat shape="STRING" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'" timezone="GMT"/>
</annox:annotate>
</xs:appinfo>
</xs:annotation>
</xs:element>
...
</xs:element>
And here are the relevant sections from my pom.xml:
...
<properties>
...
<maven-jaxb2-plugin.version>0.8.3</maven-jaxb2-plugin.version>
<jaxb2-basics.version>0.6.4</jaxb2-basics.version>
<jaxb2-value-constructor.version>3.0</jaxb2-value-constructor.version>
<solr-solrj.version>4.3.0</solr-solrj.version>
<jackson.version>2.2.2</jackson.version>
<hibernate-jpa-2.0-api.version>1.0.1.Final</hibernate-jpa-2.0-api.version>
...
</properties>
...
<build>
<plugins>
...
<!-- Generate Java sources from XSD schema files -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>${maven-jaxb2-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
<arg>-Xvalue-constructor</arg>
<arg>-Xinheritance</arg>
<arg>-enableIntrospection</arg>
</args>
<!-- Include our schema -->
<schemaDirectory>src/main/resources</schemaDirectory>
<schemaIncludes>
<include>certificate.xsd</include>
</schemaIncludes>
<bindingIncludes>
<bindings>certificate.xjb</bindings>
</bindingIncludes>
<generateDirectory>src/main/java</generateDirectory>
<generatePackage>com.company.project.generated</generatePackage>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>${jaxb2-basics.version}</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>${jaxb2-basics.version}</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-value-constructor</artifactId>
<version>${jaxb2-value-constructor.version}</version>
</plugin>
</plugins>
</configuration>
<dependencies>
<!-- SolrJ - only needed for the #Field annotation -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>${solr-solrj.version}</version>
</dependency>
<!-- Jackson2 Annotations -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- Hibernate Persistence Annotations -->
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>${hibernate-jpa-2.0-api.version}</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>
I had the same exception, this fixed it. Just be aware that my example puts everything into the XSD and not into the XJB... but the dependency-thing mentioned above should help you as well.

JAXB fails to generate Java classes for XBRL

I'm trying to generate Java classes for types defined in XBRL.
My build process is based on Maven 2, and here are my trials. I only paste the build section, which relies on some properties:
package is the name of my target package
catalog is the path and file name of the catalog. because I have no internet connection, I have amny entries, but I think those are always necessary
-- TR9401 for XBRL resources --
SYSTEM http://www.xbrl.org/2003/XLink http/www.xbrl.org/2003/xl-2003-12-31.xsd
SYSTEM http://www.w3.org/1999/xlink http/www.xbrl.org/2003/xlink-2003-12-31.xsd
xsd.path is the directory where the XSD resides
xsd.file is the file name of the following minimalist XSD
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://www.xbrl.org/2003/instance"
schemaLocation="http://www.xbrl.org/2003/xbrl-instance-2003-12-31.xsd"/>
</xs:schema>
All plugins I have tried fail to import xl:nonEmptyURI.
But xl is mapped to http://www.xbrl.org/2003/XLink (which is in my catalog) which imports <import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink-2003-12-31.xsd"/> which defines nonEmptyURI
What's wrong? How can I fix it?
Apache CXF
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<xsdOptions>
<xsdOption>
<catalog>${catalog}</catalog>
<xsd>${xsd.path}/${xsd.file}</xsd>
<packagename>${package}</packagename>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
Fails with
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xl:nonEmptyURI' to a(n) 'type definition' component.
line 389 of cache/http/www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
jvnet maven-jaxb2-plugin
<plugin>
<!-- http://jaxb.java.net/ -->
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<id>generate</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<catalog>${catalog}</catalog>
<schemaDirectory>${xsd.path}</schemaDirectory>
<generatePackage>${package}</generatePackage>
<strict>false</strict>
<extension>true</extension>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version>0.6.4</version>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>0.6.4</version>
</plugin>
</plugins>
<args>
<arg>-Xannotate</arg>
<arg>-XtoString</arg>
</args>
</configuration>
</plugin>
The error is the same, a little more verbose
[INFO] Parsing input schema(s)...
[ERROR] Error while parsing schema(s).Location [ cache/http/www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd{389,74}].
org.xml.sax.SAXParseException: undefined simple type 'xl:nonEmptyURI'
at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
at com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
[...]
[ERROR] Error while parsing schema(s).Location [ cache/http/www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd{412,77}].
org.xml.sax.SAXParseException: undefined simple type 'xl:nonEmptyURI'
at com.sun.xml.xsom.impl.parser.ParserContext$1.reportError(ParserContext.java:180)
at com.sun.xml.xsom.impl.parser.NGCCRuntimeEx.reportError(NGCCRuntimeEx.java:175)
at com.sun.xml.xsom.impl.parser.DelayedRef.resolve(DelayedRef.java:110)
[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.8.2:generate (generate) on project solvency2: Unable to parse input schema(s). Error messages should have been provided. -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.8.2:generate (generate) on project solvency2: Unable to parse input schema(s). Error messages should have been provided.
Mojo jaxb2-maven-plugin
<plugin>
<!--http://mojo.codehaus.org/ -->
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${xsd.path}</schemaDirectory>
<packageName>${package}</packageName>
<catalog>${catalog}</catalog>
</configuration>
</plugin>
Same error, said differently by Xerces
[ERROR] file:[...]cache/http/www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd[472,74]
org.xml.sax.SAXParseException: src-resolve: Cannot resolve the name 'xl:nonEmptyURI' to a(n) 'simpleType definition' component.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
You definitely need all schemas to be downloaded and added to catalog in your case. I had a similar problem with generating Java classes, but I didn't use any catalogs at all just put all the schemas the XBRL uses into the same folder. The same way they're organized on XBRL site:
src\main\resources\xbrl\
xbrl-instance-2003-12-31.xsd
xbrl-linkbase-2003-12-31.xsd
xl-2003-12-31.xsd
xlink-2003-12-31.xsd
xbrl_bindings.xjb
Also I added a JAXB binding as you can see to resolve a conflict that raises during the source generation and put into the same folder.
xbrl_bindings.xjb:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
version="2.1">
<bindings schemaLocation="xl-2003-12-31.xsd" version="1.0">
<bindings node="//xs:schema//xs:element[#name='title']">
<property name="xlTitle"/>
</bindings>
</bindings>
Maven plugin configuration:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>xsdtojava</goal>
</goals>
<configuration>
<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
<xsdOptions>
<xsdOption>
<bindingFile>${path.to.xsd}/xbrl_bindings.xjb</bindingFile>
<xsd>${path.to.xsd}/xbrl-instance-2003-12-31.xsd</xsd>
</xsdOption>
</xsdOptions>
</configuration>
</execution>
</executions>
</plugin>
Enjoy XBRL :)
In your catalog, you probably need to change SYSTEM with PUBLIC.
See also: this article
According to this article, PUBLIC is used for matching a namespace URI:
-- Match address.xsd by URL --
SYSTEM "http://www.example.com/address/address.xsd" "imports/address.xsd"
-- Match phone-number.xsd by namespace URI --
PUBLIC "http://www.example.com/phone-number" "imports/phone-number.xsd"
Did you download the XSD and put it in an imports folder?

Resources