1

I am trying to generate Java classes from a XSD schema using the xjc command that comes with JAXB.

My schema looks like:

<xs:schema xmlns="..." 
           xmlns:ext="http://schemas.myco.com/ext" ... >
  <xs:import namespace="http://schemas.myco.com/ext" 
             schemaLocation="http://myco.com/schemas/ext.xsd"/>
  ...

The problem is that the schemaLocation URI does not exist and I can not modify the XSD file. That is why the generation process fails with errors such as "src-resolve: Cannot resolve the name 'ext:Resource_Type' to a(n) 'type definition' component".

Is there any way to force JAXB to use a local copy of ext.xsd file during the process without modifying the original XSD file ?

Guido
  • 46,642
  • 28
  • 120
  • 174

1 Answers1

3

Two possible solutions:

JAXB Episode File: http://weblogs.java.net/blog/2006/09/05/separate-compilation-jaxb-ri-21

or

XML Catalogs (search Google)

maximdim
  • 8,041
  • 3
  • 33
  • 48
  • Thank you. I'll try both. I didn't know about the first one (I hope it is compatible with jaxb2-maven-plugin), and I've been trying to use a catalog with an entry such as "PUBLIC namespace_url local_path" with no success (any good link in this sense?). Thanks. – Guido Dec 09 '10 at 22:30
  • According to http://confluence.highsource.org/display/MJIIP/User+Guide your first proposed alternative seems to work with maven-jaxb2-plugin. I'll post my results asap. – Guido Dec 09 '10 at 22:48
  • It doesn't work. I've asked it as a new question related to episodic compilation here http://stackoverflow.com/questions/4510818/jaxb-episodic-compilation-with-maven – Guido Dec 22 '10 at 15:42
  • Unfortunately, the [XML Catalogs](http://wiki.eclipse.org/Using_the_XML_Catalog) defined in Eclipse are not used when runnning "Generate > JAXB Classes" (in a JPA faceted project) – rds Oct 15 '12 at 10:30
  • Did you manage to solve the issue ? I think I'm having the similar one, my XSD contains local paths but still it gives src-resolve error. The path is relative in schemaLocation in my case – Abdul Fatah Jan 14 '20 at 08:19