[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.modeling.m2m] Re: [ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute"

Dear Mikael and All,

Well, my metamodels are really generated from XMLSchema using EMF facilities.I use xsd schema create genmodel , create a product model instance using emf api and java code gengerated from genmodel, the result is right. Even I remove metadata(EAnnotation) from ecore , and I happened to find that if I change "ecore:EAttribute" 's "upperBound" property value to -1 (if none, default is 1), the target model is right.

There are snippets:

<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String";>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData";>
<details key="kind" value="attribute"/>
<details key="name" value="code"/>
</eAnnotations>
</eStructuralFeatures>


   to :

<eStructuralFeatures xsi:type="ecore:EAttribute" name="code" unique="false" upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String";>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData";>
<details key="kind" value="attribute"/>
<details key="name" value="code"/>
</eAnnotations>
</eStructuralFeatures>


By the way,I try to test more complex example, metamodel still generated from schema using EMF facilities

	<?xml version="1.0" encoding="UTF-8"?>
	<schema xmlns="http://www.w3.org/2001/XMLSchema";
		xmlns:ns="http://www.m2matl.com/product";
		xmlns:xsd="http://www.w3.org/2001/XMLSchema";
		targetNamespace="http://www.m2matl.com/product";>
		<element name="product" type="ns:Product" />
		<complexType name="Product">
			<sequence>
				<element name="name" type="xsd:string" />
				<element ref="ns:person" minOccurs="0" maxOccurs="1" />
			</sequence>
		</complexType>
		<element name="person" type="ns:Person" abstract="true" />
		<complexType name="Person" />
		<element name="author" type="ns:Author" substitutionGroup="ns:person" />	
		<complexType name="Author">
			<complexContent>
				<extension base="ns:Person">
					<sequence>
						<element name="name" type="xsd:string" />
						<element name="mail" type="xsd:string" />
					</sequence>
				</extension>
			</complexContent>
		</complexType>
	</schema>

transform this model to itsslef.
product.xml:
<Product xmlns="http://www.m2matl.com/product";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:ns="http://www.m2matl.com/product";>
<name>aaaa</name>
<!--<person xsi:type="Author"> -->
<person xsi:type="ns:Author"> <name>asdd</name>
<age>123</age>
</person>
</Product>

when atl engineer(AtlEMFModelHandler) load this model,throw exceptions as below:

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@101cb7b (eClass: org.eclipse.emf.ecore.impl.EClassImpl@164538f (name: Author) (instanceClassName: null) (abstract: false, interface: false))' is not legal. (platform:/resource/Smaple4/models/product.xml, 7, 31)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:80)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:189)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:179)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1089)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:895)
at org.atl.engine.repositories.emf4atl.ASMEMFModel.loadASMEMFModel(ASMEMFModel.java:323)
at org.atl.eclipse.engine.AtlEMFModelHandler.loadModel(AtlEMFModelHandler.java:122)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.loadModel(AtlLaunchConfigurationDelegate.java:275)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.getSourceModels(AtlLaunchConfigurationDelegate.java:333)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.runAtlLauncher(AtlLaunchConfigurationDelegate.java:205)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.runAtlLauncher(AtlLaunchConfigurationDelegate.java:168)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.runAtlLauncher(AtlLaunchConfigurationDelegate.java:145)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.runAtlLauncher(AtlLaunchConfigurationDelegate.java:121)
at org.atl.eclipse.adt.launching.AtlLaunchConfigurationDelegate.launch(AtlLaunchConfigurationDelegate.java:97)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:639)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:565)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:754)
at org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlugin.java:944)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@101cb7b (eClass: org.eclipse.emf.ecore.impl.EClassImpl@164538f (name: Author) (instanceClassName: null) (abstract: false, interface: false))' is not legal. (platform:/resource/Smaple4/models/product.xml, 7, 31)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2382)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2367)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTypeName(XMLHandler.java:1842)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:1768)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1576)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:876)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:854)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:626)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:179)
... 17 more
Caused by: java.lang.IllegalArgumentException: The feature 'person' is not a valid changeable feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:706)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:682)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:653)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1091)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2377)
... 35 more



I haven't readed atl source codes too much , but I traced the problem in debug model, find that the product's metamodel is load suceessfully, when load product.xml as a model it occurs the problem. I think maybe it's a problem about emf4atl.


Please help me, if the ecore file created from EMF facilities can't be used ,can anyone give me a sample which conform to the product's schema.By the way,how to transform elements having realtionship of "extend" like product.xml(IN model) to itsself,any help would be appreciated very much!
Thanks in andvance!



Best Regards, Shan