Home » Modeling » TMF (Xtext) » Re: Reading multiple XML models of different XSD's
Re: Reading multiple XML models of different XSD's [message #641021] |
Tue, 23 November 2010 22:12 |
Ed Merks Messages: 33216 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 '...'
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | | |
Re: Reading multiple XML models of different XSD's [message #641652 is a reply to message #641283] |
Fri, 26 November 2010 14:22 |
Helge Mising name Messages: 17 Registered: October 2010 |
Junior Member |
|
|
Hi,
Sorry for bringing this up again. But I am still stuck with this problem and would really appreciate any hint that can point me into the right direction to find a solution.
I wrote a workflow component that dumps all EPackages that are registered in the workflow. That is, it writes out all entries of (EPackage.Registry.INSTANCE.entrySet()) and both EPackages are registered under the URI of the corresponding XSD metamodel. The following very basic workflow:
Workflow {
bean = StandaloneSetup {
registerGeneratedEPackage = "dk.itu.sdg.entityEca.EntityEca.EntityEcaPackage"
registerGeneratedEPackage = "dk.itu.sdg.entitymodel.Entitymodel.EntitymodelPackage"
}
bean = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
metaModelPackage = "dk.itu.sdg.entitymodel.Entitymodel.EntitymodelPackage"
}
bean = org.eclipse.xtend.typesystem.emf.EmfMetaModel {
metaModelPackage = "dk.itu.sdg.entityEca.EntityEca.EntityEcaPackage"
}
component = dk.itu.sdg.entitymodel.Entitymodel.util.RegistryChecker {
printRegistryContents = true
}
component = dk.itu.sdg.entitymodel.Entitymodel.util.EntitymodelReader {
modelSlot = "m1"
uri = "/Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/entitymodel.xml"
}
component = dk.itu.sdg.entityEca.EntityEca.util.EntityEcaReader {
modelSlot = "m2"
uri = "/Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/eecas.xml"
}
}
generates this output:
0 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Adding generated EPackage 'dk.itu.sdg.entityEca.EntityEca.EntityEcaPackage'
106 [main] INFO lipse.emf.mwe.utils.StandaloneSetup - Adding generated EPackage 'dk.itu.sdg.entitymodel.Entitymodel.EntitymodelPackage'
121 [main] DEBUG .Entitymodel.util.EntitymodelReader - Whoopti... reading dk.itu.sdg.entitymodel.Entitymodel.util.EntitymodelReader
140 [main] DEBUG yEca.EntityEca.util.EntityEcaReader - Whoopti... reading dk.itu.sdg.entityEca.EntityEca.util.EntityEcaReader
http://dtds/entitymodel.xsd dk.itu.sdg.entitymodel.Entitymodel.impl.EntitymodelPackageImpl
http://www.eclipse.org/emf/2003/XMLType org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl
http://www.eclipse.org/2008/xtext/parsetree org.eclipse.xtext.parsetree.impl.ParsetreePackageImpl
http://www.eclipse.org/emf/2002/Ecore org.eclipse.emf.ecore.impl.EcorePackageImpl
http://www.eclipse.org/xtext/common/mwe2/Mwe2 org.eclipse.emf.mwe2.language.mwe2.impl.Mwe2PackageImpl
http://www.eclipse.org/2008/Xtext org.eclipse.xtext.impl.XtextPackageImpl
http://www.eclipse.org/xtext/common/JavaVMTypes org.eclipse.xtext.common.types.impl.TypesPackageImpl
http://dtds/entity-eca.xsd dk.itu.sdg.entityEca.EntityEca.impl.EntityEcaPackageImpl
330 [main] ERROR mf.mwe2.launch.runtime.Mwe2Launcher - Problems running workflow workflow.A: Couldn't load resource under /Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file:///Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/entitymodel.xml, 22, 82)
java.lang.RuntimeException: Problems running workflow workflow.A: Couldn't load resource under /Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file:///Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/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 /Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/entitymodel.xml : org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature 'entitymodel' not found. (file:///Documents/eclipse/helios/runtime-modeling/applications/accounting/entitydef/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
That is the EPackages are registered. Do I oversee something very basic, that I have to do, to make this example run?
I have the impression that the problem is not, that the EPackages are not registered, but that there is an issue with the model element names, since they first get capitalized and second they are renamed to "_modelElementName_Type" ("Type" is attached). In the XML files that are read the model element names and package element names are still
But this does not really explain why I can read and seralize XML models of one metamodel but not of multiple metamodels.
a) Is there anyone who reads XML models not with the XSDAdapter but with, e.g., org.eclipse.emf.mwe.utils.Reader?
b) If so, how do you do this?
c) What did you do for populating your EMF Project?
I just followed the wizard. That is, created an EMF project from an XML schema. Then, I changed the URI in the EPackage from the file URI pointing to the XSD model to the same http URI that is used in the XML modles to refer to their metamodels. Subsequently I generated the model code.
d) Did you generate an xsd2ecore mapping model? Is this necessary? If so, how did you make your workflow aware of the mapping model?
Best,
Helge
|
|
|
Goto Forum:
Current Time: Thu Sep 19 15:47:26 GMT 2024
Powered by FUDForum. Page generated in 0.03079 seconds
|