Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » Resolving XSD includes
Resolving XSD includes [message #604393] Fri, 09 October 2009 15:50 Go to next message
Tom Fennelly is currently offline Tom Fennelly
Messages: 6
Registered: July 2009
Junior Member
Hi.

I'm using v2.2.3 of the Eclipse XSD API. I'm using it standalone to read some XSDs.

In one particular case, I have an XSD that has a number of include elements, including complex type definitions from other schemas. My issue is that my XSDResource does not appear to be able to resolve the included XSDs and so all my element declarations are coming back as XSDSimpleTypeDefinition types.

I'm sure I'm just missing a step in the code to enable this. Here's what I have:
Resource resource = new XSDResourceFactoryImpl().createResource(schemaURI);
XSDSchema schema;

resource.load(Collections.EMPTY_MAP);
schema = (XSDSchema) resource.getContents().get(0);

schema.validate();

List<XSDDiagnostic> diagnostics = schema.getAllDiagnostics();
if (!diagnostics.isEmpty()) {
throw new SchemaException(diagnostics);
}

....


I'm fairly sure it's not a relative paths issue because I'm passing a fully qualified path as the URI. Also, my IDE is able to navigate between the XSDs just fine. So as I say... I'm guessing that I'm just missing a step in the code, or simply making an invalid assumption re the external schemas being resolved automatically.

Any help would be appreciated.
Re: Resolving XSD includes [message #604396 is a reply to message #604393] Fri, 09 October 2009 17:16 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26088
Registered: July 2009
Senior Member
Tom,

Comments below.

Tom Fennelly wrote:
> Hi.
>
> I'm using v2.2.3 of the Eclipse XSD API. I'm using it standalone to
> read some XSDs.
That's a lot of years ago...
>
> In one particular case, I have an XSD that has a number of include
> elements, including complex type definitions from other schemas. My
> issue is that my XSDResource does not appear to be able to resolve the
> included XSDs and so all my element declarations are coming back as
> XSDSimpleTypeDefinition types.
>
> I'm sure I'm just missing a step in the code to enable this. Here's
> what I have:
> Resource resource = new
> XSDResourceFactoryImpl().createResource(schemaURI);
Yep, that's looking bad. Unless you load into a resource set, other
resources can't be loaded.
> XSDSchema schema;
>
> resource.load(Collections.EMPTY_MAP);
> schema = (XSDSchema) resource.getContents().get(0);
>
> schema.validate();
>
> List<XSDDiagnostic> diagnostics = schema.getAllDiagnostics();
> if (!diagnostics.isEmpty()) {
> throw new SchemaException(diagnostics);
> }
>
> ...
>
>
> I'm fairly sure it's not a relative paths issue because I'm passing a
> fully qualified path as the URI. Also, my IDE is able to navigate
> between the XSDs just fine. So as I say... I'm guessing that I'm just
> missing a step in the code, or simply making an invalid assumption re
> the external schemas being resolved automatically.
Have a look at XSDMainExample. In particular, you need to use a
ResourceSet to load the initial resources so that included resources can
be demand loaded into it.
>
> Any help would be appreciated.
Previous Topic:Displaying selected content from XSD file
Next Topic:Resolving XSD includes
Goto Forum:
  


Current Time: Thu Oct 02 00:38:36 GMT 2014

Powered by FUDForum. Page generated in 0.07785 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software