Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » noNamespaceSchemaLocation URI resolution with catalog entry
noNamespaceSchemaLocation URI resolution with catalog entry [message #1069612] Tue, 16 July 2013 08:34 Go to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Hi,

I have created an EMF model from a XSD, and generated the corresponding editor.
I have added "xml" to the extensions of this editor so that I can open a xml file with it.

My xml file defines a "xsi:noNamespaceSchemaLocation" attribute with an abstract URI for which an entry "System" has been defined in the xml catalog in order to resolve the abstration.

When opening my xml file with the editor, it appears that the xml catalog entry has not been used for the abstract URI resolution and the editor can not open my file.

What should I do ? Do I have to override a method of the generated editor ? If so which one and how ? Else, what should I do ?

Thank you.
Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1069629 is a reply to message #1069612] Tue, 16 July 2013 09:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Vincent,

Comments below.

On 16/07/2013 10:34 AM, Vincent De Bry wrote:
> Hi,
>
> I have created an EMF model from a XSD, and generated the
> corresponding editor.
> I have added "xml" to the extensions of this editor so that I can open
> a xml file with it.
It sounds like you need to make use of content types in this case.
>
> My xml file defines a "xsi:noNamespaceSchemaLocation" attribute with
> an abstract URI for which an entry "System" has been defined in the
> xml catalog in order to resolve the abstration.
XML catalog isn't something provided by EMF nor something EMF is aware
of. EMF has similar mechanisms, i.e., URI mappings in the URI
converter. Such mappings can even be defined in the plugin.xml...

Are you using
http://wiki.eclipse.org/index.php/EMF/FAQ#How_can_I_ensure_that_an_xsi:schemaLocation_is_serialized_for_my_packages.3F
>
> When opening my xml file with the editor, it appears that the xml
> catalog entry has not been used for the abstract URI resolution and
> the editor can not open my file.
>
> What should I do ? Do I have to override a method of the generated
> editor ? If so which one and how ? Else, what should I do ?
It sounds like you should make use of content types. You can configure
that in the GenPackage's properties. If you use something older than
EMF 2.9, you need to delete the plugin.xml files (including the editor's
one) to regenerate them.
>
> Thank you.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1069643 is a reply to message #1069629] Tue, 16 July 2013 09:52 Go to previous messageGo to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Hi Ed,

Thank you for your help.

the eNS_URI used in my "initializePackageContents" is the path to my real schema ("platform:/resource/com.debry.xmleditor/schema/ComponentType.xsd")

trying to override the createResource method with the abstract URI ("debry:ComponentType.xsd") does not make it work.

I have also tried to modify the "plugin.properties" of the generated editor with
"_UI_ComponentTypeEditorFilenameExtensions = componenttype,xml", by adding ",xml" as I understood your proposal, but I still got the following exception while opening my xml file with the editor:

org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'debry:ComponentType.xsd' not found. (platform:/resource/MyProject/myComponent/component.xml, 3, 128)


Probably I did not catch correctly your thought.

[Updated on: Tue, 16 July 2013 09:55]

Report message to a moderator

Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1069790 is a reply to message #1069643] Tue, 16 July 2013 15:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Vincent,

Comments below.


On 16/07/2013 11:52 AM, Vincent De Bry wrote:
> Hi Ed,
>
> Thank you for your help.
>
> the eNS_URI used in my "initializePackageContents" is the path to my
> real schema
> ("platform:/resource/com.debry.xmleditor/schema/ComponentType.xsd")
This kind of assumes the model is always in the workspace as a project.
That doesn't seem like a good assumption.
>
> trying to override the createResource method with the abstract URI
> ("debry:ComponentType.xsd") does not make it work.
What's the purpose of that?
>
> I have also tried to modify the "plugin.properties" of the generated
> editor with
> "_UI_ComponentTypeEditorFilenameExtensions = componenttype,xml", by
> adding ",xml" as I understood your proposal, but I still got the
> following exception while opening my xml file with the editor:
>
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'softima:ComponentType.xsd' not found.
> (platform:/resource/SoftArcadiaProject/01-Components/myComponent/component.xml,
> 3, 128)
>
> Probably I did not catch correctly your thought.
Did you find the GenPackage? It has a Content Type Identifier property
you can set so something like org.example.your.package and the
regenerated. The plugin.xml for the model and editor should reflect
this change. If you're using older releases of EMF that don't support
plugin.xml merging, you can delete those and regenerate them.

Are you actually using the generated resource factory to create your
resource? That should just work out of the box without all the stuff
you mention you're doing.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1070044 is a reply to message #1069790] Wed, 17 July 2013 06:27 Go to previous messageGo to next message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
I have finally succeeded to make it work by loading my xml file like this:
ResourceFactoryRegistryImpl.INSTANCE.getExtensionToFactoryMap().put("xml", componentTypeResourceFactoryImpl);
ResourceSet resourceSet = new ResourceSetImpl();
String locUri = myXmlFile.getLocation().toString();
URI xmlModelURI = URI.createFileURI(locUri);

Resource resource = resourceSet.getResource(xmlModelURI, true);

where "componentTypeResourceFactoryImpl" comes from the generated model.

Thank's again, Ed, for your support.
Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1070060 is a reply to message #1070044] Wed, 17 July 2013 07:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Vincent,

If you're running in the workspace, you should use platform:/resource
URIs:
http://wiki.eclipse.org/index.php/EMF-FAQ#How_do_I_map_between_an_EMF_Resource_and_an_Eclipse_IFile.3F

On 17/07/2013 8:27 AM, Vincent De Bry wrote:
> I have finally succeeded to make it work by loading my xml file like
> this:
>
> ResourceFactoryRegistryImpl.INSTANCE.getExtensionToFactoryMap().put("xml",
> componentTypeResourceFactoryImpl);
> ResourceSet resourceSet = new ResourceSetImpl();
> String locUri = myXmlFile.getLocation().toString();
> URI xmlModelURI = URI.createFileURI(locUri);
>
> Resource resource = resourceSet.getResource(xmlModelURI, true);
>
> where "componentTypeResourceFactoryImpl" comes from the generated model.
>
> Thank's again, Ed, for your support.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: noNamespaceSchemaLocation URI resolution with catalog entry [message #1070066 is a reply to message #1070060] Wed, 17 July 2013 07:28 Go to previous message
Vincent De Bry is currently offline Vincent De BryFriend
Messages: 55
Registered: May 2013
Member
Thank's Ed, I just did it and it still works Smile.
I have now another issue. I will open another post.
Previous Topic:Re: Registering a resource factory on a file name
Next Topic:getting resource from model element
Goto Forum:
  


Current Time: Thu Apr 18 15:16:53 GMT 2024

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

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

Back to the top