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 #490669] 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 #490690 is a reply to message #490669] Fri, 09 October 2009 17:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
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/
Re: Resolving XSD includes [message #490701 is a reply to message #490690] Fri, 09 October 2009 18:15 Go to previous messageGo to next message
Tom Fennelly is currently offline Tom FennellyFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks Ed...

Ed Merks wrote on Fri, 09 October 2009 13:16
That's a lot of years ago...


Smile

It was the latest version I found in the public maven repo, so I just used that Smile

Ed Merks wrote on Fri, 09 October 2009 13:16
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.


Ahhh OK Ed... thanks!!! I'll give that a go.

I sort-of worked around it by manually and recursively loading the types from the schemas referenced by the import and include elements (in the XSDSchema contents). Would obviously be nicer to use the proper mechanisms, so thanks for that Ed!!
Re: Resolving XSD includes [message #604400 is a reply to message #490690] Fri, 09 October 2009 18:15 Go to previous message
Tom Fennelly is currently offline Tom FennellyFriend
Messages: 6
Registered: July 2009
Junior Member
Thanks Ed...

Ed Merks wrote on Fri, 09 October 2009 13:16
> That's a lot of years ago...


:)

It was the latest version I found in the public maven repo, so I just used that :)

Ed Merks wrote on Fri, 09 October 2009 13:16
> 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.


Ahhh OK Ed... thanks!!! I'll give that a go.

I sort-of worked around it by manually and recursively loading the types from the schemas referenced by the import and include elements (in the XSDSchema contents). Would obviously be nicer to use the proper mechanisms, so thanks for that Ed!!
Previous Topic:Resolving XSD includes
Next Topic:Create new DOM document from XSD schema
Goto Forum:
  


Current Time: Thu Apr 25 19:55:14 GMT 2024

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

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

Back to the top