users@jersey.java.net

Fwd: [Jersey] JAXB schemagen ant task and namespaces (Help Jakub :-)

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Wed, 29 Apr 2009 08:37:53 +0200

Hi Mark,

Cross posting to the metro users list.

Paul.

Begin forwarded message:

> From: "Rabick, Mark A (IS)" <Mark.Rabick_at_ngc.com>
> Date: April 28, 2009 7:39:39 PM CEDT
> To: users_at_jersey.dev.java.net
> Subject: [Jersey] JAXB schemagen ant task and namespaces (Help
> Jakub :-)
> Reply-To: users_at_jersey.dev.java.net
>
> I have a set of JAXB annotated java classes that I'm trying to
> generate an XSD schema from. I'm trying to change the default
> output generated file from schema1.xsd with no success. The classes
> are in the directory:
>
> src/com/cnodb/rs/model
>
> In the file: src/com/cnodb/rs/model/v1/package-info.java
>
> I have a packege level JAXB XmlSchema annotation:
>
> @javax.xml.bind.annotation.XmlSchema (
> xmlns = {
> @javax.xml.bind.annotation.XmlNs(prefix = "cnodb-v1",
> namespaceURI="http://www.cnodb.com/v1"),
>
> @javax.xml.bind.annotation.XmlNs(prefix="xs",
> namespaceURI="http://www.w3.org/2001/XMLSchema")
> }
> )
> package com.cnodb.rs.model.v1;
>
> The ant task is defined in my build.xml as follows:
>
> <taskdef name="schemagen"
> classname="com.sun.tools.jxc.SchemaGenTask">
> <classpath>
> <path refid="Web App Libraries.libraryclasspath"/>
> <path refid="JAXB Build Support.userclasspath"/>
> </classpath>
> </taskdef>
>
> The ant target calling schemagen is:
>
> <target name="build.xml.schema" depends="init">
> <schemagen srcdir="src/com/cnodb/rs/model"
> destdir="build/schemas">
> <schema namespace="http://www.cnodb.com/v1"
> file="cnodb-v1.xsd"/>
> </schemagen>
> </target>
>
> According to the JAXB site at: https://jaxb.dev.java.net/nonav/2.1.11/docs/schemagenTask.html
>
> The nested schema element under the schemagen invocation should
> produce the output file cnodb-v1.xsd for my defined namespace but
> the target is producing the default file "schema1.xsd".
>
> I can workaround this by just renaming the file at present because I
> have a single namespace but we may be federating our namespaces
> because of some shared elements with another project.
>
> I have the JAXB 2.1 distribution https://jaxb.dev.java.net/2.1.10/JAXB2_20090206.jar
>
> A final note, none of the sample JAXB apps use the nested schema
> element.
>
> Using JDK 1.6.0_12.
>
> --mark
> _______________________________________________
> Mark A. Rabick
> Em: mark.rabick_at_ngc.com
>