Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Very odd issue with multiple schemaLocations
Very odd issue with multiple schemaLocations [message #1015558] Fri, 01 March 2013 08:57 Go to next message
Eclipse UserFriend
Hello,

I'm creating XSD based Ecore models and serialize them. To get proper
schema locations, I have set the URI of the resource owning the XSD
model to point to the path where the schemas are. Saving with
XMLResource.OPTION_SCHEMA_LOCATION = Boolean.TRUE worked fine so far.
The serialized result looks like this (line breaks added for better
readability):

xmlns:common="http://www.abc.com/product/0.3.0/common"
xmlns:main="http://www.abc.com/product/0.3.0/main"
xsi:schemaLocation="
http://www.abc.com/product/0.3.0/common
../../../../model/com.abc.model/bin/xsd/Common-v0.3.0.xsd
http://www.abc.com/product/0.3.0/main
../../../../model/com.abc.model/bin/xsd/Main-v0.3.0.xsd"

All fine so far. But now I moved the XML file one level down in the
directory hierarchy. To match that I added one "../" to the
schemaLocation. But now the XML file no longer validates, claiming that
the Common-v0.3.0.xsd cannot be located anymore!

If I remove the first schema location (common), it works again!

That brings me to the next question: is it actually correct to have
multiple schemaLocations like this? Main.xsd will imply pulling in
Common.xsd anyway.

Please note that I am aware that the validation is done by WST and not
EMF, but since the XML was serialized by EMF, I thought I ask here first.

Thanks for any tipps or pointers!

Marius
Re: Very odd issue with multiple schemaLocations [message #1015630 is a reply to message #1015558] Fri, 01 March 2013 13:00 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Marius,

Comments below.

On 01/03/2013 9:57 AM, Marius Gröger wrote:
> Hello,
>
> I'm creating XSD based Ecore models and serialize them. To get proper
> schema locations, I have set the URI of the resource owning the XSD
> model to point to the path where the schemas are.
What path did you use?
> Saving with
> XMLResource.OPTION_SCHEMA_LOCATION = Boolean.TRUE worked fine so far.
> The serialized result looks like this (line breaks added for better
> readability):
>
> xmlns:common="http://www.abc.com/product/0.3.0/common"
> xmlns:main="http://www.abc.com/product/0.3.0/main"
> xsi:schemaLocation="
> http://www.abc.com/product/0.3.0/common
> ../../../../model/com.abc.model/bin/xsd/Common-v0.3.0.xsd
It's in your bin folder? Is this supposed to work once you've deployed
your model?
> http://www.abc.com/product/0.3.0/main
> ../../../../model/com.abc.model/bin/xsd/Main-v0.3.0.xsd"
>
> All fine so far. But now I moved the XML file one level down in the
> directory hierarchy. To match that I added one "../" to the
> schemaLocation. But now the XML file no longer validates, claiming that
> the Common-v0.3.0.xsd cannot be located anymore!
You might try using this in your resource factory:

result.getDefaultSaveOptions().put(XMLResource.OPTION_URI_HANDLER, new
URIHandlerImpl.PlatformSchemeAware());

Assuming you've specified the location as platform:/plugin/ (although it
doesn't look like you have done that).
>
> If I remove the first schema location (common), it works again!
What's "it"?
>
> That brings me to the next question: is it actually correct to have
> multiple schemaLocations like this? Main.xsd will imply pulling in
> Common.xsd anyway.
In general schemaLocations are specified to be "hints" to the XML
processor. Processors can choose to ignore them and can choose to use
any mechanism for locating schemas.
>
> Please note that I am aware that the validation is done by WST and not
> EMF, but since the XML was serialized by EMF, I thought I ask here first.
If you want WST to validate your XML, you're probably better off to use
their catalog mechanism to specify where your namespace's schema should
be found, rather than specifying it in each instance.
>
> Thanks for any tipps or pointers!
>
> Marius
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[Teneo] Strange behaviour when switching EntityNameStrategy
Next Topic:Virtual Nodes in TreeViewer based on EMF
Goto Forum:
  


Current Time: Thu Apr 18 06:22:02 GMT 2024

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

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

Back to the top