|
Re: [emf] question on ordering elements in ecore model [message #719434 is a reply to message #719414] |
Sat, 27 August 2011 05:47 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 26/08/2011 6:38 PM, tsurdilo wrote:
> Hi all, I am fairly new to EMF so please bare with me :)
>
> In my ecore model I define two nodes: A and B where A extends from B:
>
> node A (contains some other elements x,y,z):
> A -> B
> x
> y
> z
>
> node B (contains elements a, b ; abstract=true):
> B
> a
> b
>
> When I generate the output XML what happens is this:
>
> <A>
> <a/>
> <b/>
> <x/>
> <y/>
> <z/>
> </A>
>
> Is there _any_ way to tell EMF that I really want
>
> <A>
> <x/>
> <y/>
> <z/>
> <a/>
> <b/>
> </A>
By specializing the serializer, but...
>
> because I have to conform to an external schema which has a sequence
> that have to adhere to for A.
How is the external schema defining A and B? If B is a complex type
and A extends it then then order would be exactly as it is in EMF, i.e.,
with B's elements first followed by A's extension, so I'm confused how
it could be otherwise.
> I guess I am asking is there any way to tell EMF I want the elements
> of the concrete node A to be printed _before_ elements of the abstract
> node that it extends?
What you describe sounds contradictory... Can you show an example of a
schema that does what you describe?
>
> Thanks for any input!
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: [emf] question on ordering elements in ecore model [message #719535 is a reply to message #719514] |
Sat, 27 August 2011 16:42 |
Ed Merks Messages: 33217 Registered: July 2009 |
Senior Member |
|
|
Comments below.
On 27/08/2011 8:14 AM, tsurdilo wrote:
> Hi Ed, thank your for the reply. Here is the concrete example of what
> I am working with (BPMN2):
>
> OMG Semantic.xsd schema:
> http://www.omg.org/spec/BPMN/20100501/Semantic.xsd has defined for the
> process element:
Oh, one of those semi-useless OMG schemas. Your model uses multiple
inheritance but that's not supported in XML Schema, so one does a bunch
of copying to "approximate" it or one uses model and attribute groups
which are no better than a macro.
>
>
> <xsd:element name="process" type="tProcess"
> substitutionGroup="rootElement"/>
> <xsd:complexType name="tProcess">
> <xsd:complexContent>
> <xsd:extension base="tCallableElement">
> <xsd:sequence>
> <xsd:element ref="auditing" minOccurs="0" maxOccurs="1"/>
> <xsd:element ref="monitoring" minOccurs="0" maxOccurs="1"/>
> <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="laneSet" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="flowElement" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="artifact" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="resourceRole" minOccurs="0" maxOccurs="unbounded"/>
> <xsd:element ref="correlationSubscription" minOccurs="0"
> maxOccurs="unbounded"/>
> <xsd:element name="supports" type="xsd:QName" minOccurs="0"
> maxOccurs="unbounded"/>
> </xsd:sequence>
> <xsd:attribute name="processType" type="tProcessType" default="None"/>
> <xsd:attribute name="isClosed" type="xsd:boolean" default="false"/>
> <xsd:attribute name="isExecutable" type="xsd:boolean"/>
> <xsd:attribute name="definitionalCollaborationRef" type="xsd:QName"
> use="optional"/>
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
>
> eclipse.bpmn2 model (BPMN20.ecore ->
> https://github.com/eclipse/bpmn2/tree/master/org.eclipse.bpmn2/model)
> has:
Given the specification is defining both a schema and a model, it's
rather stupid they'd define an order that puts base class features in
the middle of the locally defined features. A problem with the OMG is
that they focus on specifications with reference implementations as an
afterthought. Actually, reference implementations aren't even
considered, so problems crop of long after the specification has been
cast in stone.
>
>
>
> and the abstract node it extends (FlowElementContainer for example) has:
>
>
>
> When generating output bpmn2 with the eclipse.bpmn2 api (this is just
> one example) the process element in the xml output first includes the
> elements of the FlowElementContainer node, then it includes the
> elements that are within the Process node (for for example laneset
> would come _before_ property) and in any bpm runtime engine that does
> schema validation, this fails unfortunately and I have to manually
> rearrange the bpmn2 to get it to conform to Semantic.xml, unless I
> turn off schema validation completely.
> Hope this is what you were asking. Any input is much appreciated!
Using OPTION_USE_CACHED_LOOKUP_TABLE you could create your own
implementation of XMLSaveImpl.Lookup where you could override
getFeatures to return features in the order you want them to appear in
the XML.
>
> Thanks.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
Re: [emf] question on ordering elements in ecore model [message #730634 is a reply to message #719547] |
Wed, 28 September 2011 18:43 |
tsurdilo Messages: 41 Registered: February 2011 |
Member |
|
|
Hi Ed, I found some time for this now, and looking at XmlSaveImpl in it's init method it first gets the OPTION_USE_CACHED_LOOKUP_TABLE object via:
@SuppressWarnings("unchecked") List<Object> lookup = (List<Object>)options.get(XMLResource.OPTION_USE_CACHED_LOOKUP_TABLE);
and if the lookup table is provided (not emty) it tries to cast it to the Lookup class:
featureTable = (Lookup)lookup.get(INDEX_LOOKUP);
the Lookup class has signature:
protected static class Lookup {
...
}
This then (unless I am wrong) does not allow me to create own impl of the Lookup class outside of org.eclipse.emf.ecore.xmi.impl package. I would want to be able to do this in the client app code instead if possible.
Thanks.
[Updated on: Wed, 28 September 2011 18:43] Report message to a moderator
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05442 seconds