You may use the namespace-prefix plugin from jaxb2-common project (disclaimer : I wrote it) :
https://github.com/Siggen/jaxb2-namespace-prefix
This is a xjc pluging which allows to define namespace -> prefix mappings within the bindings.xml file :
<jxb:bindings schemaLocation="eCH-0007-3-0.xsd">
<jxb:schemaBindings>
<jxb:package name="ch.ech.ech0007.v3" />
</jxb:schemaBindings>
<jxb:bindings>
<namespace:prefix name="eCH-0007" />
</jxb:bindings>
</jxb:bindings>
Which will results in the following package-info.java file being generated (mind the added XmlNs annotation) :
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.ech.ch/xmlns/eCH-0007/3", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "http://www.ech.ch/xmlns/eCH-0007/3", prefix = "eCH-0007-3")
})
package ch.ech.ech0007.v3;
Your pom.xml would look like :
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.8.0</version>
<configuration>
<schemaDirectory>src/main/resources</schemaDirectory>
<catalog>src/main/resources/catalog.xml</catalog>
<schemaIncludes>
<include>*.xsd</include>
</schemaIncludes>
<bindingDirectory>src/main/resources</bindingDirectory>
<bindingIncludes>
<include>bindings.xml</include>
</bindingIncludes>
<args>
<arg>-extension</arg>
<arg>-Xnamespace-prefix</arg>
</args>
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-namespace-prefix</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.ech.ch/xmlns/eCH-0007/3"
to@javax.xml.bind.annotation.XmlSchema(namespace = ""
? How can that be done? – Longrange