|
Re: Resolving XSD includes [message #604396 is a reply to message #604393] |
Fri, 09 October 2009 17:16 |
Ed Merks Messages: 33264 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/
|
|
|
Powered by
FUDForum. Page generated in 0.03895 seconds