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: 144
Registered: July 2015
Senior 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: 33141
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...


Ed Merks
Professional Support: https://www.macromodeling.com/
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: 144
Registered: July 2015
Senior 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: Thu Apr 25 20:42:29 GMT 2024

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

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

Back to the top