Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » 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 FennellyFriend
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 MerksFriend
Messages: 33140
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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Displaying selected content from XSD file
Next Topic:Resolving XSD includes
Goto Forum:
  


Current Time: Thu Apr 25 04:53:59 GMT 2024

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

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

Back to the top