users@jaxb.java.net

Re: Resolve the schema location from the classpath?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 17 Nov 2006 08:38:25 -0800

James Mao wrote:
> I have a problem to resolve the schema location from the classpath, i
> don't know if the jaxb xjc can resolve the schema location from classpath?
> for example:
>
> I have a xsd in which i have an import statement like following:
> <xs:import namespace="http://schemas.xmlsoap.org/wsdl/"
> schemaLocation="/schemas/wsdl/wsdl.xsd"/>

If you write like that, the actual schema location is primarily
determined by the absolutization of your relative URL
"/schemas/wsdl/wsdl.xsd". So it depends on what URL your XSD that
contains that <import> statement has.

I think such absolutization rule is well understood, because you face
that in HTTP URLs all the time.

You can affect this resolution process by using your entity resolver, or
the catalog resolver bundled in the JAXB RI. See the -catalog option and
https://jaxb.dev.java.net/nonav/2.0.4/docs/catalog.html

In that way you can have XJC read anything that's addressable by URL.

> I have the wsdl.xsd included in the schemas.jar!/schemas/wsdl/wsdl.xsd.
> and the jar is in my classpath
>
> I use the xjc maven2 plugin to generate the java artifacts, but it will
> fail due to it can not find the wsdl.xsd in the jar file.
>
> Any suggestions?



-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com