users@jaxb.java.net

Generating schema for class files in a jar

From: Nick Stolwijk <nick.stolwijk_at_gmail.com>
Date: Mon, 28 Sep 2009 17:50:57 +0200

Hi,

I am using the Maven JAXB Schemagen plugin to generate a schema for my
java files. However, a few class files are in one of the dependencies
of my module. This dependency contains a package-info.class with the
@XmlSchema annotation. This file seems not to be read, because the
schema is generated in the default namespace. Is it possible to use
the XmlSchema annotation from the jar to generate the schema?

My project layout:

-Task-Commons
     -src/main/java
             -com/example.model
                   -Person.java
                   -package-info.java
     pom.xml
-Task-Module
    -src/main/java
              -com/example/module/model
                    -Task.java
                    -package-info.java
    pom.xml

The schemagen plugin has been defined in the Task-Module pom.xml.

The Task-Module depends on the Task-Commons module.

The package-info in the Task-Module contains an XmlSchema annotation:

@javax.xml.bind.annotation.XmlSchema(namespace =
"http://www.example.com/task", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

The package-info in the Task-Commons contains an XmlSchema annotation:
@javax.xml.bind.annotation.XmlSchema(namespace =
"http://www.example.com/commons", elementFormDefault =
javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

The schemagen plugin generates two files, the first file contains the
Task element in the correct namespace, the second one contains the
Person element in the default namespace instead of the specified
namespace.

With regards,

[1] https://jaxb.dev.java.net/maven-jaxb-schemagen

Nick Stolwijk
~Java Developer~

IPROFS BV.
Claus Sluterweg 125
2012 WS Haarlem
http://www.iprofs.nl