Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » Reading multiple XML models of different XSD's
Reading multiple XML models of different XSD's [message #641009] Tue, 23 November 2010 15:41 Go to next message
Helge Mising name is currently offline Helge Mising name
Messages: 17
Registered: October 2010
Junior Member
Hi all,

I am not sure if this is the right forum since my question is related to XSD, EMF, or MWE2. If it is not the right forum I apologize.

My problem is:
I have multiple XSD metamodels. For reading the XML model instances faster than with the XSDAdapter, I created an EMF plug-in for each of the metamodels (as described for example here: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf/doc/org.eclipse.emf.doc/tutorials/xlibmod/xlibm od.html?root=Modeling_Project&view=co). Each plug-in contains a model reader which looks like this:
public class _XSDNAME_Reader extends Reader {
	public _XSDNAME_Reader(){
		super();
        Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml", new _XSDNAME_ResourceFactoryImpl());
	    EPackage.Registry.INSTANCE.put("http://dk.itu.sdg._XSDNAME_/_XSDNAME_model", _XSDNAME_PackageImpl.init());
	}
}

where "_XSDNAME_" is the name of the corresponding XSD metamodel. Now, when using this readers in an MWE2 workflow everything works smoothly as long as only models of one metamodel are read. That is, the folowing workflow reads two entitymodels correctly:
module workflow.Works
Workflow {
	
	component = EntitymodelReader {
		modelSlot = "m1"
		uri = "... /entitymodel.xml"
	}
	
	component = EntitymodelReader {
		modelSlot = "m2"
		uri = "... /entitymodel2.xml"
	}
}

Whereas a workflow that tries to read models that are instances of more than one metamodel as shown here:
module workflow.DoesNotWork
Workflow {
	
	component = EntitymodelReader {
		modelSlot = "m1"
		uri = "... /entitymodel.xml"
	}
	
	component = EntityEcaReader {
		modelSlot = "m2"
		uri = "... /eecas.xml"
	}
}

results in an exception of the form:
...
327  [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher  - Problems running workflow workflow.A: Couldn't load resource under .../entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
java.lang.RuntimeException: Problems running workflow workflow.A: Couldn't load resource under /Users/ropf/Documents/eclipse/helios/runtime-modeling/ofbiz_9_4/applications/accounting/entitydef/entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:82)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:52)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Launcher.java:74)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2Launcher.java:35)
Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException: Couldn't load resource under .../entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
	at org.eclipse.emf.mwe.utils.Reader.load(Reader.java:75)
	at org.eclipse.emf.mwe.utils.Reader.invokeInternal(Reader.java:40)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:126)
	at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.java:34)
	at org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invoke(AbstractWorkflowComponent.java:201)
	at org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkflowComponent.invoke(AbstractCompositeWorkflowComponent.java:31)
	at org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow.java:19)
	at org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runner.java:80)
	... 3 more

What is the reason for this? As mentioned, when reading multiple models that are instances of the same metamodel, everything works fine, I can even write them out to xmi files using the standard writer. That is, I assume that all features 'exist'. Is it the problem, that I register multiple resource factories to the same file extension in the readers? Or is there another reason? How to solve the problem?


Best regards,
Helge


PS: I abbreviated all pathes and file URIs with '...'

Re: Reading multiple XML models of different XSD's [message #641023 is a reply to message #641009] Tue, 23 November 2010 17:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25750
Registered: July 2009
Senior Member
Helge,

Comments below.

Helge wrote:
> Hi all,
>
> I am not sure if this is the right forum since my question is related
> to XSD, EMF, or MWE2. If it is not the right forum I apologize.
It's better to use a more specific one.
>
> My problem is: I have multiple XSD metamodels. For reading the XML
> model instances faster than with the XSDAdapter, I created an EMF
> plug-in for each of the metamodels (as described for example here:
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.emf/org .eclipse.emf/doc/org.eclipse.emf.doc/tutorials/xlibmod/xlibm od.html?root=Modeling_Project&view=co).
> Each plug-in contains a model reader which looks like this:
>
> public class _XSDNAME_Reader extends Reader {
> public _XSDNAME_Reader(){
> super();
>
> Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).put( "xml",
> new _XSDNAME_ResourceFactoryImpl());
>
> EPackage.Registry.INSTANCE.put("http://dk.itu.sdg._XSDNAME_/_XSDNAME_model",
> _XSDNAME_PackageImpl.init());
Try use use XyzPackage.eNS_URI and XyzPackage.eINSTANCE.
> }
> }
>
> where "_XSDNAME_" is the name of the corresponding XSD metamodel. Now,
> when using this readers in an MWE2 workflow everything works smoothly
> as long as only models of one metamodel are read. That is, the
> folowing workflow reads two entitymodels correctly:
>
> module workflow.Works
> Workflow {
>
> component = EntitymodelReader {
> modelSlot = "m1"
> uri = "... /entitymodel.xml"
> }
>
> component = EntitymodelReader {
> modelSlot = "m2"
> uri = "... /entitymodel2.xml"
> }
> }
>
> Whereas a workflow that tries to read models that are instances of
> more than one metamodel as shown here:
>
> module workflow.DoesNotWork
> Workflow {
>
> component = EntitymodelReader {
> modelSlot = "m1"
> uri = "... /entitymodel.xml"
> }
>
> component = EntityEcaReader {
> modelSlot = "m2"
> uri = "... /eecas.xml"
> }
> }
>
> results in an exception of the form:
>
> ..
> 327 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems
> running workflow workflow.A: Couldn't load resource under
> .../entitymodel.xml :
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
> java.lang.RuntimeException: Problems running workflow workflow.A:
> Couldn't load resource under
> /Users/ropf/Documents/eclipse/helios/runtime-modeling/ofbiz_ 9_4/applications/accounting/entitydef/entitymodel.xml
> : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runne r.java:82)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runne r.java:52)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Lau ncher.java:74)
>
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2La uncher.java:35)
>
> Caused by: org.eclipse.emf.mwe.core.WorkflowInterruptedException:
> Couldn't load resource under .../entitymodel.xml :
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
> at org.eclipse.emf.mwe.utils.Reader.load(Reader.java:75)
> at org.eclipse.emf.mwe.utils.Reader.invokeInternal(Reader.java: 40)
> at
> org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invok e(AbstractWorkflowComponent.java:126)
>
> at org.eclipse.emf.mwe.core.lib.Mwe2Bridge.invoke(Mwe2Bridge.ja va:34)
> at
> org.eclipse.emf.mwe.core.lib.AbstractWorkflowComponent.invok e(AbstractWorkflowComponent.java:201)
>
> at
> org.eclipse.emf.mwe2.runtime.workflow.AbstractCompositeWorkf lowComponent.invoke(AbstractCompositeWorkflowComponent.java: 31)
>
> at
> org.eclipse.emf.mwe2.runtime.workflow.Workflow.run(Workflow. java:19)
> at
> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runne r.java:80)
> ... 3 more
>
> What is the reason for this? As mentioned, when reading multiple
> models that are instances of the same metamodel, everything works
> fine, I can even write them out to xmi files using the standard
> writer. That is, I assume that all features 'exist'. Is it the
> problem, that I register multiple resource factories to the same file
> extension in the readers? Or is there another reason? How to solve the
> problem?
This really is an mwe2 question. I think that's usually discussed in
the tmf newsgroup, so I've added that to the "to" list of the reply.
>
>
> Best regards,
> Helge
>
>
> PS: I abbreviated all pathes and file URIs with '...'
>
>
Re: Reading multiple XML models of different XSD's [message #641163 is a reply to message #641023] Wed, 24 November 2010 08:12 Go to previous messageGo to next message
Sven Efftinge is currently offline Sven Efftinge
Messages: 1755
Registered: July 2009
Senior Member
Am 11/23/10 11:12 PM, schrieb Ed Merks:

>> 327 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems
>> running workflow workflow.A: Couldn't load resource under
>> .../entitymodel.xml :
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>> 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
>> java.lang.RuntimeException: Problems running workflow workflow.A:
>> Couldn't load resource under
>> /Users/ropf/Documents/eclipse/helios/runtime-modeling/ofbiz_ 9_4/applications/accounting/entitydef/entitymodel.xml
>> : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>> 'entitymodel' not found. (file://.../entitymodel.xml, 22, 82)
>> at
>> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runne r.java:82)
>> at
>> org.eclipse.emf.mwe2.launch.runtime.Mwe2Runner.run(Mwe2Runne r.java:52)
>> at
>> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.run(Mwe2Lau ncher.java:74)
>>
>> at
>> org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher.main(Mwe2La uncher.java:35)
>>

Looks like the EPackage used in the xml is not resolvable.
How does that xml model point to its EcorePackages (what kind of URI)?

Sven

--
Need professional support for Xtext or other Eclipse Modeling technologies?
Go to: http://xtext.itemis.com
Twitter : @svenefftinge
Blog : http://blog.efftinge.de


--
Have you heard about XtextCON?
Go to: http://www.xtextcon.org
Twitter : @svenefftinge
Blog : blog.efftinge.de
Re: Reading multiple XML models of different XSD's [message #641185 is a reply to message #641163] Wed, 24 November 2010 09:00 Go to previous messageGo to next message
Helge Mising name is currently offline Helge Mising name
Messages: 17
Registered: October 2010
Junior Member
Hi,

The XML models point to their metamodels using an http URI. See the following headers.
<entity-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http:// ... /dtds/entity-eca.xsd">

<entitymodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http:// ... /dtds/entitymodel.xsd">

Whereas the ecore metamodels that are generated out of the XSD metamodels point to the file using a file URI. Like this:
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="EntityEca"
    nsURI="file:/ ... /framework/entity/dtd/entity-eca.xsd"
    nsPrefix="EntityEca">

That is, in the package Code the nsURI line looks like this:
String eNS_URI = "file:/ ... /framework/entity/dtd/entity-eca.xsd";


Thus, I see that the ecore and XML models use different URIs and it is true the exception always points to the header in the XML files. But I do not know what to do now. I cannot change the metamodel URIs in the XML models, since they need to be unmodified. But the file URI gets generated automatically to the ecore packages by the emf wizard. I now tried to change the URI in the ecore package from the file to http URI manually and regenerated the code. But I still get the same exception...

Best,
Helge
Re: Reading multiple XML models of different XSD's [message #641223 is a reply to message #641185] Wed, 24 November 2010 09:57 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25750
Registered: July 2009
Senior Member
Helge,

Note that your replying only to the modeling newsgroup so Sven is not so
likely to see this response. Please follow up on the
eclipse.modeling.tmf newsgroup.


Helge wrote:
> Hi,
>
> The XML models point to their metamodels using an http URI. See the
> following headers.
>
> <entity-eca xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="http:// ... /dtds/entity-eca.xsd">
>
> <entitymodel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:noNamespaceSchemaLocation="http:// ... /dtds/entitymodel.xsd">
> Whereas the ecore metamodels that are generated out of the XSD
> metamodels point to the file using a file URI. Like this:
>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="EntityEca"
> nsURI="file:/ ... /framework/entity/dtd/entity-eca.xsd"
> nsPrefix="EntityEca">
> That is, in the package Code the nsURI line looks like this:
>
> String eNS_URI = "file:/ ... /framework/entity/dtd/entity-eca.xsd";
>
>
> Thus, I see that the ecore and XML models use different URIs and it is
> true the exception always points to the header in the XML files. But I
> do not know what to do now. I cannot change the metamodel URIs in the
> XML models, since they need to be unmodified. But the file URI gets
> generated automatically to the ecore packages by the emf wizard. I now
> tried to change the URI in the ecore package from the file to http URI
> manually and regenerated the code. But I still get the same exception...
To properly process instances of null namespace schemas, you must ensure
the generated resource factory is used because it does local
registration of the package (for the null namespace).
>
> Best,
> Helge
Previous Topic:EMF SOAP questions
Next Topic:ANSI-C-model and dealing with redundant references
Goto Forum:
  


Current Time: Thu Apr 24 06:32:10 EDT 2014

Powered by FUDForum. Page generated in 0.03342 seconds