users@jaxb.java.net

JAXB annotated class to include external schema

From: Alex Wibowo <alexwibowo_at_gmail.com>
Date: Tue, 26 Aug 2008 14:23:32 +1000

Hi,


I have a question regarding JAXB. I'm going to generate the XML schema from
my JAXB annotated class, which looks like:
---------------------------------------------------------------
package au.com.bla.afi.common.model.hibernate;

import au.com.bla.webservices.schema.CodeDescription;


@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "codeDescription"
})
@XmlRootElement(name = "AccessoryCategory")
public class AccessoryCategory{
....
             @XmlElement(name = "CodeDescription",namespace = "
http://webservices.bla.com.au/schema/common/Types.xsd")
             protected CodeDescription codeDescription;
.....
.....
}
---------------------------------------------------------------
and the package-info.java looks like:
--------------------------------------
@javax.xml.bind.annotation.XmlSchema(namespace = "
http://webservices.bla.com.au/schema/afi/2008/05/13/AFIDMS.xsd",
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package au.com.bla.afi.common.model.hibernate;
---------------------------------------


The problem is that "CodeDescription" is a JAXB generated class (from
another schema) which is included in the build process (JAR file) as a maven
dependency.
I'm using "maven-jaxb-schema-plugin" to generate the schema, and here is
what I have:
--------------------------------------------------------------
              <plugin>
                <groupId>com.sun.tools.jxc.maven2</groupId>
                <artifactId>maven-jaxb-schemagen-plugin</artifactId>
                <version>1.2</version>
                <executions>
                    <execution>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>

<destdir>${project.build.directory}/${groupId}.${artifactId}-${version}/2008/05/13</destdir>
                            <includes>

<include>au/com/bla/afi/common/model/hibernate/AccessoryCategory.java</include>

<include>au/com/bla/afi/common/model/hibernate/package-info.java</include>
                            </includes>
                            <schemas>
                                <schema>
                                    <namespace>
http://webservices.bla.com.au/schema/afi/2008/05/13/AFIDMS.xsd</namespace>
                                    <file>AFIDMS.xsd</file>
                                </schema>
                            </schemas>

<srcdir>${project.build.sourceDirectory}</srcdir>
                            <verbose>true</verbose>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
--------------------------------------------------------------
I cant see how the generated schema (AFIDMS.xsd) can include the external
schema (Types.xsd). i.e.
---------------------------------------------------------------
    <xsd:include schemaLocation="../../../common/Types.xsd"/>
---------------------------------------------------------
Has anyone ever done this before? Could anyone tell me the approach I need
to take?

Thanks a lot!



-- 
Best regards,
WiB