Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute" ?
[ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute" ? [message #21728] Wed, 07 March 2007 07:53 Go to next message
Eclipse UserFriend
Originally posted by: xxcs214.163.com

When I transform an example:

source model:

<book xmlns="http://www.m2matl.com/book" name="ass" code="asss">

target model which I supposed should be :

<prdocut xmlns="http://www.m2matl.com/prdocut">
<name>ass</name>
<code>asss</name>
</product>

is :

<prdocut:Prdocut xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:prdocut="http://www.m2matl.com/prdocut" code="asss" name="ass"/>

Target model'style is same as book that "name" and "code" are both
attributes.


my atl source:
-------------------
module B2P;
create OUT : Product from IN : Book;
rule Book2Product {
from
b : Book!Book
to
out : Product!Product (
name <- b.name,
code <- b.code
)
}
-------------------

Is my alt rule right or wrong?
If it is wrong, how to defiine atl rule to make sure get correct result?
else does atl engineer always transfer "Element" to "Attribute" when the
element is simpleType?


Attach metamodel source below
------------------------------------------------------------ --------------------
book's metamodel---book.ecore

<?xml version="1.0" encoding="UTF-8"?>
<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="book"
nsURI="http://www.m2matl.com/book" nsPrefix="book">
<eClassifiers xsi:type="ecore:EClass" name="Book">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Book"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
unique="false" lowerBound="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="element"/>
<details key="name" value="name"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="code"
unique="false" lowerBound="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="element"/>
<details key="name" value="code"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value=""/>
<details key="kind" value="mixed"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
unique="false" upperBound="-1"
eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementWildcard"/>
<details key="name" value=":mixed"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="xMLNSPrefixMap"
upperBound="-1"
eType="ecore:EClass
http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
transient="true" containment="true" resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="xmlns:prefix"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference"
name="xSISchemaLocation" upperBound="-1"
eType="ecore:EClass
http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
transient="true" containment="true" resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="xsi:schemaLocation"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="book"
upperBound="-2" eType="#//Book"
volatile="true" transient="true" derived="true" containment="true"
resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="book"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
------------------------------------------------------------ ---------------------

product's metamodel---product.ecore

<?xml version="1.0" encoding="UTF-8"?>
<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="product"
nsURI="http://www.m2matl.com/product" nsPrefix="product">
<eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value=""/>
<details key="kind" value="mixed"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
unique="false" upperBound="-1"
eType="ecore:EDataType
http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementWildcard"/>
<details key="name" value=":mixed"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="xMLNSPrefixMap"
upperBound="-1"
eType="ecore:EClass
http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
transient="true" containment="true" resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="xmlns:prefix"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference"
name="xSISchemaLocation" upperBound="-1"
eType="ecore:EClass
http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
transient="true" containment="true" resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="xsi:schemaLocation"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EReference" name="product"
upperBound="-2"
eType="#//Product" volatile="true" transient="true" derived="true"
containment="true"
resolveProxies="false">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="element"/>
<details key="name" value="product"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Product">
<eAnnotations
source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="Product"/>
<details key="kind" value="empty"/>
</eAnnotations>
<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>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
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="name"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
Re: [ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute" [message #21866 is a reply to message #21728] Wed, 07 March 2007 16:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Dear Shan,

Seeing your metamodels, I suppose you get your metamodels from XMLSchema
using EMF facilities.

The fact is that metamodels build from XMLSchema add some metadata
(EAnnotation) to know how to serialize documents. Thus, this is not a
ATL issue but an EMF issue. As i don't really know those EMF's features,
i advise you to get in touch with EMF's guys ;)

Regards,
Mikael

Shan wrote :
> When I transform an example:
>
> source model:
>
> <book xmlns="http://www.m2matl.com/book" name="ass" code="asss">
> target model which I supposed should be :
>
> <prdocut xmlns="http://www.m2matl.com/prdocut">
> <name>ass</name>
> <code>asss</name>
> </product>
>
> is :
>
> <prdocut:Prdocut xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:prdocut="http://www.m2matl.com/prdocut" code="asss" name="ass"/>
>
> Target model'style is same as book that "name" and "code" are both
> attributes.
>
>
> my atl source:
> -------------------
> module B2P; create OUT : Product from IN : Book;
> rule Book2Product {
> from b : Book!Book to out : Product!Product (
> name <- b.name, code <- b.code )
> }
> -------------------
>
> Is my alt rule right or wrong? If it is wrong, how to defiine atl rule
> to make sure get correct result? else does atl engineer always transfer
> "Element" to "Attribute" when the element is simpleType?
>
>
> Attach metamodel source below
> ------------------------------------------------------------ --------------------
>
> book's metamodel---book.ecore
> <?xml version="1.0" encoding="UTF-8"?>
> <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="book"
> nsURI="http://www.m2matl.com/book" nsPrefix="book">
> <eClassifiers xsi:type="ecore:EClass" name="Book">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Book"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> unique="false" lowerBound="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="element"/>
> <details key="name" value="name"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="code"
> unique="false" lowerBound="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="element"/>
> <details key="name" value="code"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value=""/>
> <details key="kind" value="mixed"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
> unique="false" upperBound="-1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="elementWildcard"/>
> <details key="name" value=":mixed"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xMLNSPrefixMap" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="xmlns:prefix"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xSISchemaLocation" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="xsi:schemaLocation"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="book"
> upperBound="-2" eType="#//Book"
> volatile="true" transient="true" derived="true"
> containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="book"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
> ------------------------------------------------------------ ---------------------
>
>
> product's metamodel---product.ecore
> <?xml version="1.0" encoding="UTF-8"?>
> <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="product"
> nsURI="http://www.m2matl.com/product" nsPrefix="product">
> <eClassifiers xsi:type="ecore:EClass" name="DocumentRoot">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value=""/>
> <details key="kind" value="mixed"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mixed"
> unique="false" upperBound="-1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="elementWildcard"/>
> <details key="name" value=":mixed"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xMLNSPrefixMap" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="xmlns:prefix"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="xSISchemaLocation" upperBound="-1"
> eType="ecore:EClass
> http://www.eclipse.org/emf/2002/Ecore#//EStringToStringMapEn try"
> transient="true" containment="true" resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="xsi:schemaLocation"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EReference" name="product"
> upperBound="-2"
> eType="#//Product" volatile="true" transient="true"
> derived="true" containment="true"
> resolveProxies="false">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> <details key="name" value="product"/>
> <details key="namespace" value="##targetNamespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Product">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="Product"/>
> <details key="kind" value="empty"/>
> </eAnnotations>
> <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>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> 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="name"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
>



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
Re: [ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute" [message #22330 is a reply to message #21866] Fri, 09 March 2007 09:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: xxcs214.163.com

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(XMLL oadImpl.java:80)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:189)
at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1089)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:895)
at
org.atl.engine.repositories.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:323)
at
org.atl.eclipse.engine.AtlEMFModelHandler.loadModel(AtlEMFMo delHandler.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(L aunchConfiguration.java:639)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:565)
at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:754)
at
org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlu gin.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(XM LHandler.java:2382)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2367)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:1842)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1768)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1576)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:876)
at
org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:854)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:626)
at
com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at
com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
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(Basi cEObjectImpl.java:706)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:682)
at
org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:653)
at
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1091)
at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.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
Re: [ATL]Does ATL Engineer always transfer "Element"(SimpleType) to "Attribute" [message #25496 is a reply to message #22330] Fri, 23 March 2007 23:04 Go to previous message
Frédéric Jouault is currently offline Frédéric JouaultFriend
Messages: 572
Registered: July 2009
Senior Member
Hello,

ATL uses EMF to read and write the target models.
I am not sure if EMF interprets the annotations generated by the XML
Schema to Ecore metamodel transformation when used in reflective mode.

You might want to try using your metamodel "by URI" (i.e., installing
the plugin generated from your metamodel in Eclipse, and referring to
the nsURI of your metamodel in the launch config rather than loading the
..ecore file).


Another solution to generate custom XML is to use the XML extractor.
Please see the following howto regarding tuning the XML output of ATL:
http://wiki.eclipse.org/index.php/ATL_Howtos#How_can_I_tune_ the_XML_output_of_ATL.3F

You may also be interested in:
http://wiki.eclipse.org/index.php/ATL_Howtos#How_can_I_handl e_arbitrary_XML_documents.3F


Regards,

Frédéric Jouault


Shan wrote:
> 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(XMLL oadImpl.java:80)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:189)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:179)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1089)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:895)
>
> at
> org.atl.engine.repositories.emf4atl.ASMEMFModel.loadASMEMFMo del(ASMEMFModel.java:323)
>
> at
> org.atl.eclipse.engine.AtlEMFModelHandler.loadModel(AtlEMFMo delHandler.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(L aunchConfiguration.java:639)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:565)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:754)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$6.run(DebugUIPlu gin.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(XM LHandler.java:2382)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.java:2367)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromTy peName(XMLHandler.java:1842)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHa ndler.java:1768)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1576)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:876)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:82)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:854)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:626)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDispatcher.dispatch(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown 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(Basi cEObjectImpl.java:706)
>
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:682)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjec tImpl.java:653)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHel perImpl.java:1091)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XM LHandler.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
>
>
>
>
>
>
Previous Topic:[ATL] "Warning, could not find mathing node for ForEachOutPatternElement..."
Next Topic:[ATL] How to run ATL from program in silent mode
Goto Forum:
  


Current Time: Tue Mar 19 09:01:23 GMT 2024

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

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

Back to the top