Resolving XSD includes [message #490669] |
Fri, 09 October 2009 11:50  |
Eclipse User |
|
|
|
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 #604400 is a reply to message #490690] |
Fri, 09 October 2009 14:15  |
Eclipse User |
|
|
|
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!!
|
|
|
Powered by
FUDForum. Page generated in 0.03787 seconds