Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Extracting information from extendedMetaData(How to get/read information from an xsd:complexType/xsd:simpleContent)
[QVTo] Extracting information from extendedMetaData [message #630045] Thu, 30 September 2010 13:47
Peter  is currently offline Peter Friend
Messages: 4
Registered: June 2010
Junior Member
Obviously, I am a QVT beginner who have only done a few simple transformations.
- Now I have problem with extracting information defined as a "xs:extension base" in a xs:complexType with xs:simpleContent.

To explain my "process" in detail, I have done a small example:

A simple source xml file: (members.xml)...

<?xml version='1.0'?>
<members>
<person membertype="original" age="37">Joe</person>
<person membertype="guest" age="16">Ann</person>
<person membertype="prospect" age="42">John</person>
<person membertype="original" age="35">Liz</person>
<person membertype="original" age="56">Mary</person>
</members>

...which could be defined by following schema: (members.xsd)...
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema ecore:documentRoot="Model" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" elementFormDefault="qualified">
<xs:element name="members" type="memberstype"/>
<xs:complexType name="memberstype">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="person"/>
</xs:sequence>
</xs:complexType>
<xs:element name="person" type="persontype"/>
<xs:complexType name="persontype">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="age" use="required" type="xs:string"/>
<xs:attribute name="membertype" use="required" type="xs:string"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>

Next step in my process is to create a EMF project in Eclipse...
- New -> EMFProject -> XMLSchema(members.xsd), which gives=>
* members.genmodel (from which "helping functions" are generated by "Generate All")
* members.ecore (which is bigger than one might think Wink

members.ecore (interesting(?) parts):
<eClassifiers xsi:type="ecore:EClass" name="Persontype">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="persontype"/>
<details key="kind" value="simple"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//String">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value=":0"/>
<details key="kind" value="simple"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="age" 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="attribute"/>
<details key="name" value="age"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="membertype" 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="attribute"/>
<details key="name" value="membertype"/>
<details key="namespace" value="##targetNamespace"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>

As far as what I have been able to read about xsd mapping to ecore, this seems to be correct...
- "value" is a "new" ecore:EAttribute with an annotation different from the other "normal" attributes ("age" and "membertype")

If a run a QVT program with the above as a base I can not extract the value of the "new" attribute "value".

As a small test, the following QVT code snippet:
memberModel.objects()[Persontype]->forEach(person) {
log('***********************************');
log('person_value', person.value);
log('person_age', person.age);
log('person_membertype', person.membertype);
};

gives following output:
***********************************
person_value
person_age, data: 56
person_membertype, data: original
***********************************
person_value
person_age, data: 16
person_membertype, data: guest
***********************************
person_value
person_age, data: 35
person_membertype, data: original
***********************************
person_value
person_age, data: 37
person_membertype, data: original
***********************************
person_value
person_age, data: 42
person_membertype, data: prospect

Another thing - probably(?) related - is that when I open the xml file with "Sample Reflective Ecore Model Editor" I get similar "behaviour":
For PersonType:person: The attributes "age" and "membertype" gets mapped but the new attribute "value" becomes empty...

What I am doing wrong? Can someone helpful please direct me!

Thanks in advance,
Peter
Previous Topic:[ATL] XML extractor
Next Topic:[ATL] A strange Error message
Goto Forum:
  


Current Time: Thu Jun 20 17:36:12 GMT 2019

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

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

Back to the top