Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD => Ecore mapping without FeatureMaps
XSD => Ecore mapping without FeatureMaps [message #1800086] Wed, 19 December 2018 16:55 Go to next message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 56
Registered: July 2015
Member
Is there any way to map an XSD to ecore without using FeatureMaps?
So usually for the following, we get a featuremap:
<xs:element name="A">
    <xs:complexType>
        <xs:sequence maxOccurs="unbounded">
            <xs:element name="B" type="BType" />
            <xs:element name="C" type="CType" />
        </xs:sequence>
    </xs:complexType>
</xs:element>


So I am looking for a way to define an ecore model which does not use featuremaps but can export valid XMLs according to the schema.

My approach was to use a common superclass for BType and CType (e.g. BCType) and add a plain list of this to the Class A.
But in the XML Export I always get entries of BCType which are of course not in the schema.
Re: XSD => Ecore mapping without FeatureMaps [message #1800107 is a reply to message #1800086] Thu, 20 December 2018 05:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30685
Registered: July 2009
Senior Member
I assume you still want to preserve the relative mixed order of B and C elements. If not, you could use ecore:featureMap="" on the xs:sequence. That will give you an EClass A with two separate containment references for B and C, but of course all Bs will be serialized before all Cs.

An alternative is to change the schema to express the XML serialization using substitution groups and using the approach described in this very old blog entry to produce a clean API for it that nevertheless serializes in a way that conforms to your schema:

http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html

I think it will be a problem though that it then uses global elements that will be qualified, but your original schema likely has unqualified elements B and C...
Re: XSD => Ecore mapping without FeatureMaps [message #1800147 is a reply to message #1800107] Thu, 20 December 2018 12:59 Go to previous message
Robert Schulk is currently offline Robert SchulkFriend
Messages: 56
Registered: July 2015
Member
Thats exactly what we would have needed, but unfortunately: yes the original schema uses unqualified elements.

We're going to use a workaround this time, but this is good to know for the future!
Previous Topic:Xcore and JUnit4/5
Next Topic:Ignoring whitespace before XML header
Goto Forum:
  


Current Time: Sat Dec 07 11:09:02 GMT 2019

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

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

Back to the top