users@jaxb.java.net

Re: Resolve the schema location from the classpath?

From: Kenny MacLeod <kennym_at_kizoom.com>
Date: Thu, 31 Jul 2008 08:17:25 +0100

Are you trying to create a Schema object? If so, SchemaFactory just
needs the InputStream of the schema file, and you can get this from
Class.getResourceAsStream("/path/to/schema.xsd")

I use Spring's Resource abstraction for this sort of thing. Very nice.

ostracke wrote:
> Hello,
>
> I´m confronted with the same problem. Yes, of course I
> could set the URL in my catalog to something like
> "jar:file:...!/path/to/schema.xsd".
> But than I have to know the exact name and location of
> the jar, which is not very nice especially working in a maven
> project.
> I would like to set it to something like "classpath:/path/to/schema.xsd".
> Or alternatively I would like to set an entityResolver instead
> of a catalog file, so I could care for resolving the dependent
> schemas on my own.
>
> Does anybody know a solution to this problem?
>
> Thanks in advance,
> Olaf
>
>
>
> Kohsuke Kawaguchi wrote:
>> James Mao wrote:
>>> entity resolver you mentioned may solve my problem, but i don't know how
>>> to add the entity resolver into the xjc maven plugin, do you know how or
>>> where's the doc?
>> I believe the plugin should have associated documents. If not, please
>> contact their authors.
>>
>>
>>> I think the catalog has the same problem, it'll not look into the
>>> classpath to resolve the schemaLocation, right?
>> The issue is really not so much as to whether something can "look into
>> the classpath". All the resources in a jar has an URL. So all you need
>> to do is to make sure XJC gets that URL.
>>
>> --
>> Kohsuke Kawaguchi
>> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Resolve-the-schema-location-from-the-classpath--tp7372851p18735106.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>