Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » adding an import to a schema and validating
adding an import to a schema and validating [message #69690] Fri, 08 September 2006 14:45 Go to next message
Eclipse UserFriend
Originally posted by: x86core.yahoo.com

I was wondering how I should add an import to a XSDSchema object and
validate the schema with the added import. I have looked up the newsgroup
but could not get much. The example code was not helpful in this regard
either. I have been trying to execute the following code without much
avail.

<code>
private void addImport(String nameSpace, String absolutePath,
XSDSchema resolvedSchema) {
XSDSchema schema = null;
XSDImport impDirective = XSDFactory.eINSTANCE.createXSDImport();
impDirective.setNamespace(nameSpace);
impDirective.setSchemaLocation(absolutePath);
impDirective.setResolvedSchema(resolvedSchema);

// schema.getReferencingDirectives().add(impDirective); //this does not
// work either
schema.getContents().add(impDirective); // this result in an error The
// sdDiagnostics say the import is not allowed by constraint
// expecting type......
schema.clearDiagnostics();
schema.validate();
}
}
<code/>
Thanks and regards,
Nero.
Re: adding an import to a schema and validating [message #69711 is a reply to message #69690] Fri, 08 September 2006 15:23 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Nero,

Note that imports must appear before any definitions or declarations in
the schema's contents. So probably doing schema.getContents().add(0,
impDirective) will do the trick. And typically the resolved schema is
computed from the schemaLocation in the context of the containing schema
to which you add the directive, i.e., it's not something you usually set
directly.


nero wrote:
> I was wondering how I should add an import to a XSDSchema object and
> validate the schema with the added import. I have looked up the
> newsgroup but could not get much. The example code was not helpful in
> this regard either. I have been trying to execute the following code
> without much avail.
>
> <code>
> private void addImport(String nameSpace, String absolutePath,
> XSDSchema resolvedSchema) {
> XSDSchema schema = null;
> XSDImport impDirective = XSDFactory.eINSTANCE.createXSDImport();
> impDirective.setNamespace(nameSpace);
> impDirective.setSchemaLocation(absolutePath);
> impDirective.setResolvedSchema(resolvedSchema);
>
> // schema.getReferencingDirectives().add(impDirective); //this
> does not
> // work either
> schema.getContents().add(impDirective); // this result in an
> error The
> // sdDiagnostics say the import is not allowed by constraint
> // expecting type......
> schema.clearDiagnostics();
> schema.validate();
> }
> }
> <code/>
> Thanks and regards,
> Nero.
>
>
Re: adding an import to a schema and validating [message #69730 is a reply to message #69711] Fri, 08 September 2006 17:36 Go to previous message
Eclipse UserFriend
Originally posted by: x86core.yahoo.com

Thanks.I will try out your suggestion and post back.Regarding the
resolving of schemas.Totally agree with you that its something that i
should leave the schema to do.But I have certainly noticed some problems
with resolution of imports/includes....some problems with schemalocations
and relative paths.I may not be able to illustrate this....as this was
some time back.....so I would justify it by saying i have a small
mechanism to ensure things ....just to be sure.If i can recollect the
problem i'll try to produce some sample files and the exact problem.
Re: adding an import to a schema and validating [message #598743 is a reply to message #69690] Fri, 08 September 2006 15:23 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Nero,

Note that imports must appear before any definitions or declarations in
the schema's contents. So probably doing schema.getContents().add(0,
impDirective) will do the trick. And typically the resolved schema is
computed from the schemaLocation in the context of the containing schema
to which you add the directive, i.e., it's not something you usually set
directly.


nero wrote:
> I was wondering how I should add an import to a XSDSchema object and
> validate the schema with the added import. I have looked up the
> newsgroup but could not get much. The example code was not helpful in
> this regard either. I have been trying to execute the following code
> without much avail.
>
> <code>
> private void addImport(String nameSpace, String absolutePath,
> XSDSchema resolvedSchema) {
> XSDSchema schema = null;
> XSDImport impDirective = XSDFactory.eINSTANCE.createXSDImport();
> impDirective.setNamespace(nameSpace);
> impDirective.setSchemaLocation(absolutePath);
> impDirective.setResolvedSchema(resolvedSchema);
>
> // schema.getReferencingDirectives().add(impDirective); //this
> does not
> // work either
> schema.getContents().add(impDirective); // this result in an
> error The
> // sdDiagnostics say the import is not allowed by constraint
> // expecting type......
> schema.clearDiagnostics();
> schema.validate();
> }
> }
> <code/>
> Thanks and regards,
> Nero.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: adding an import to a schema and validating [message #598748 is a reply to message #69711] Fri, 08 September 2006 17:36 Go to previous message
Eclipse UserFriend
Originally posted by: x86core.yahoo.com

Thanks.I will try out your suggestion and post back.Regarding the
resolving of schemas.Totally agree with you that its something that i
should leave the schema to do.But I have certainly noticed some problems
with resolution of imports/includes....some problems with schemalocations
and relative paths.I may not be able to illustrate this....as this was
some time back.....so I would justify it by saying i have a small
mechanism to ensure things ....just to be sure.If i can recollect the
problem i'll try to produce some sample files and the exact problem.
Previous Topic:adding an import to a schema and validating
Next Topic:Feature request: can XSDEcoreBuilder use EcorePackage.eINSTANCE.getEFactoryInstance() instead of
Goto Forum:
  


Current Time: Thu Apr 25 00:23:37 GMT 2024

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

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

Back to the top