Skip to main content



      Home
Home » Modeling » EMF » XSD->Ecore Mapping for unbounded sequences
XSD->Ecore Mapping for unbounded sequences [message #1017771] Tue, 12 March 2013 10:04 Go to next message
Eclipse UserFriend
Hi,
I'm pretty sure this issue has been brought up before but I can't see any resolution. Perhaps this one http://www.eclipse.org/forums/index.php?t=msg&goto=492935

So I have created an ecore model based on an XSD. The XSD uses a sequence which has maxOccurs="unbounded" to state two elements can appear together an unlimited number of times within another element. They must sit together in this order. For example:

<xs:element name="Range">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element ref="min"/>
<xs:element ref="max"/>
</xs:sequence>
</xs:complexType>
</xs:element>

However, this restriction seems to be lost upon converting to ecore as my out models have the min and max elements stuck together e.g.

<range>
<min/>
<min/>
<min/>
<min/>
<min/>
<min/>
<max/>
<max/>
<max/>
<max/>
</range>

How can I give the ecore serializer a hint not to do this to my XML?

I found a similar issue on the boards on in this link, http://www.google.se/#hl=sv&sclient=psy-ab&q=xsd+ecore+mapping&oq=xsd+ecore+mapping&gs_l=hp.3..0i30j0i8i30.1021542.1023930.9.1024139.9.9.0.0.0.1.255.1432.2j4j3.9.0...0.0...1c.1.5.psy-ab.MMHNdCZ2jhE&pbx=1&bav=on.2,or.r_qf.&bvm=bv.43287494,d.Yms&fp=ad4b0d7c9fcf90d4&biw=1680&bih=848 (see section Multiplicity at the Sequence or Choice Level)

I know I could fix the original schema to avoid this issue but I don't have this possibility open to me.

Any help is appreciated!
Regards,
Ronan

[Updated on: Tue, 12 March 2013 11:02] by Moderator

Re: XSD-&gt;Ecore Mapping for unbounded sequences [message #1017831 is a reply to message #1017771] Tue, 12 March 2013 12:02 Go to previous messageGo to next message
Eclipse UserFriend
Ronan,

Comments below.

On 12/03/2013 3:04 PM, Ronan B wrote:
> Hi,
> I'm pretty sure this issue has been brought up before but I can't see
> any resolution. I have created an ecore model based on an XSD. The XSD
> uses a sequence which has maxOccurs="unbounded" to state two elements
> can appear together an unlimited number of times within another
> element. They must sit together in this order. For example:
>
> <xs:element name="Range">
> <xs:complexType>
> <xs:sequence minOccurs="0" maxOccurs="unbounded">
> <xs:element ref="min"/>
> <xs:element ref="max"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> However, this restriction seems to be lost upon converting to ecore as
> my out models have the min and max elements stuck together e.g.
> <range>
> <min/>
> <min/>
> <min/>
> <min/>
> <min/>
> <min/>
> <max/>
> <max/>
> <max/>
> <max/>
> </range>
>
> How can I give the ecore serializer a hint not to do this to my XML?
You'd need to add an annotation to the schema, i.e., add
ecore:featureMap="rangeElements", so that a feature map that records the
mixed order of the two different "min"/"max" features.

> I found a similar issue on the boards on in this link,
> http://www.google.se/#hl=sv&sclient=psy-ab&q=xsd+ecore+mapping&oq=xsd+ecore+mapping&gs_l=hp.3..0i30j0i8i30.1021542.1023930.9.1024139.9.9.0.0.0.1.255.1432.2j4j3.9.0...0.0...1c.1.5.psy-ab.MMHNdCZ2jhE&pbx=1&bav=on.2,or.r_qf.&bvm=bv.43287494,d.Yms&fp=ad4b0d7c9fcf90d4&biw=1680&bih=848
> (see section Multiplicity at the Sequence or Choice Level)
>
> I know I could fix the original schema to avoid this issue but I don't
> have this possibility open to me.
It can't be done without at least add an annotation...
>
> Any help is appreciated!
> Regards,
> Ronan
Re: XSD-&gt;Ecore Mapping for unbounded sequences [message #1017884 is a reply to message #1017831] Tue, 12 March 2013 13:43 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,
Thanks for your time. Hmm that is essentially what I had from the XSD->Ecore converter, except the FeatureMap was called group. I have tried regenerating again with your hint included in the XSD and I see the same behaviour from the Ecore serializer. My XSD snippet is now:

<xs:element name="Range">
<xs:complexType>
<xs:sequence minOccurs="0" maxOccurs="unbounded" ecore:featureMap="rangeElements">
<xs:element ref="min"/>
<xs:element ref="max"/>
</xs:sequence>
</xs:complexType>
</xs:element>

In fact I see that the order of the output is determined by the contents of each min/max elements. The serializer is ordering based on their values, within a given element type, rather than the XSD structure e.g.

<min>11</min>
<min>12</min>
<max>13</max>
<max>14</max>

instead of
<min>11</min>
<max>13</max>
<min>12</min>
<max>14</max>


The serializer seems to ignore the importance of the order Sad Any other suggestions?

Regards,
Ronan

[Updated on: Tue, 12 March 2013 13:46] by Moderator

Re: XSD-&amp;gt;Ecore Mapping for unbounded sequences [message #1017930 is a reply to message #1017884] Tue, 12 March 2013 16:21 Go to previous messageGo to next message
Eclipse UserFriend
Ronan,

Comments below.

On 12/03/2013 6:43 PM, Ronan B wrote:
> Hi Ed,
> Thanks for your time. Hmm that is essentially what I had from the
> XSD->Ecore converter, except the FeatureMap was called group.
I see. I didn't check...
> I have tried regenerating again with your hint included in the XSD and
> I see the same behaviour from the Ecore serializer. My XSD snippet is
> now:
>
> <xs:element name="Range">
> <xs:complexType>
> <xs:sequence minOccurs="0" maxOccurs="unbounded"
> ecore:featureMap="rangeElements">
> <xs:element ref="min"/>
> <xs:element ref="max"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> In fact I see that the order of the output is determined by the
> contents on the min/max elements.
It should be determined from the order in the feature map...
> The serializer is ordering based on their values rather than the XSD
> structure e.g.
> <min>11</min>
> <min>12</min>
> <max>13</max>
> <max>14</max>
>
> instead of <min>11</min>
> <max>13</max>
> <min>12</min>
> <max>14</max>
>
>
> The serializer seems to ignore the importance of the order :( Any
> other suggestions?
The serializer will respect the order in the model (in the feature map),
it won't validate that this order is correct. The patches in the oldest
open bugzilla are designed to help with that:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210

But I don't think I'll ever find time for it...
>
> Regards,
> Ronan
Re: XSD-&amp;gt;Ecore Mapping for unbounded sequences [message #1017969 is a reply to message #1017930] Tue, 12 March 2013 18:04 Go to previous message
Eclipse UserFriend
Hi,
Okay thanks I think I get it now.

So basically I have to make sure the FeatureMap gets filled in the correct order and with the correct number of min/max elements. The serialization will run properly as it will just loop over my correctly built FeatureMap.

Thanks again!
Ronan
Previous Topic:Create Papyrus Project From UML file Using Java
Next Topic:Persisting a complete model into one file
Goto Forum:
  


Current Time: Fri Jul 04 11:44:10 EDT 2025

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

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

Back to the top