Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XML Schema vs. XML Schema for XMI
XML Schema vs. XML Schema for XMI [message #418769] Tue, 29 April 2008 11:40 Go to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

The genmodel editor includes a wizard for exporting to both plain XML Schema and
XML Schema for XMI. What's the difference? Is it "just" ID/IDREF handling or
some deeper differences. Do I have to export to XML Schema for XMI if I want to
define/document the format of Ecore model serialization?

Hallvard
Re: XML Schema vs. XML Schema for XMI [message #418774 is a reply to message #418769] Tue, 29 April 2008 12:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33146
Registered: July 2009
Senior Member
Hallvard,

You'll probably find I've ranted on this subject before. Just have a
look at each and you'll see the differences are glaring. The XMI
schema is generated the way the XMI specification describes it. It's
almost completely devoid of meaningful validation constraints and I
would describe it as the most complex way to turn of validation that I
could imagine. But if you are producing XMI serializations, that's
pretty much the schema you'll need. The XML Schema we produce is
designed to make Ecore -> XSD ->Ecore be a round trip and is designed to
match the way XMLResourceImpl will save instances. Since XML Schema
doesn't support multiple inheritance, there's really no way in general
(in the presence of multiple inheritance) to produce a fully meaningful
schema


Hallvard Trætteberg wrote:
> Hi,
>
> The genmodel editor includes a wizard for exporting to both plain XML
> Schema and XML Schema for XMI. What's the difference? Is it "just"
> ID/IDREF handling or some deeper differences. Do I have to export to
> XML Schema for XMI if I want to define/document the format of Ecore
> model serialization?
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML Schema vs. XML Schema for XMI [message #418779 is a reply to message #418774] Tue, 29 April 2008 13:50 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Ed Merks wrote:
> You'll probably find I've ranted on this subject before. ... I
> would describe it as the most complex way to turn of validation that I
> could imagine. But if you are producing XMI serializations, that's
> pretty much the schema you'll need.

:-)

I'm doing this in the context of SOAP, where XML Schemas are used to define the
messages that will be exchanged (WSDL is the other part). Contrary to what I
believed some days ago, I don't think direct XMI serialization is suitable for
creating SOAP messages, although convenient. The main reason is how natural the
XML feels, which is important when the format is meant to be "open" and
"understandable", instead of just a practical technical encoding format.

I believe I can model both cases fairly well with Ecore, but one will be a
normal Ecore model (the XMI case), the other will be a model of the XML (the
standard XML Schema case).

Consider a phonebook case, where a Person contains PhoneNumbers. A service for
setting the mobile number of a Person can be modelled in two ways:
1) setPhoneNumber(Person person, PhoneNumber number)
2) setPhoneNumber(String personId, PhoneNumber number)
The first is natural from an Ecore perspective, and implicitly relies on XMI for
handling ID/IDREFs and hence is less XML-friendly. The second relies on an
explicit id and lookup as the mechanism for finding the correct Person object
(on the server) and more directly models the SOAP message XML that needs to be
constructed. A PhoneNumber will in both cases be thought of as a struct without
identity.

The advantage of using XML serialization instead of XMI serialization is that it
is easier to work with for non-XMI-based tools, like soapGUI and testing
tools. In addition, sometimes the XML Schema already exists, and the Ecore model
is "just" a more structured model of the data. The downside is that it requires
more manual work when modeling the operations and constructing the XML (I plan
to use Javascript and E4X as described in
http://www.ibm.com/developerworks/webservices/library/ws-aja x1/ for the latter).

Hallvard
Re: XML Schema vs. XML Schema for XMI [message #418781 is a reply to message #418779] Tue, 29 April 2008 14:18 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33146
Registered: July 2009
Senior Member
Hallvard,

Comments below.

Hallvard Trætteberg wrote:
> Ed Merks wrote:
>> You'll probably find I've ranted on this subject before. ... I would
>> describe it as the most complex way to turn of validation that I
>> could imagine. But if you are producing XMI serializations, that's
>> pretty much the schema you'll need.
>
> :-)
>
> I'm doing this in the context of SOAP, where XML Schemas are used to
> define the messages that will be exchanged (WSDL is the other part).
> Contrary to what I believed some days ago, I don't think direct XMI
> serialization is suitable for creating SOAP messages, although
> convenient. The main reason is how natural the XML feels, which is
> important when the format is meant to be "open" and "understandable",
> instead of just a practical technical encoding format.
>
> I believe I can model both cases fairly well with Ecore, but one will
> be a normal Ecore model (the XMI case), the other will be a model of
> the XML (the standard XML Schema case).
>
> Consider a phonebook case, where a Person contains PhoneNumbers. A
> service for setting the mobile number of a Person can be modelled in
> two ways:
> 1) setPhoneNumber(Person person, PhoneNumber number)
> 2) setPhoneNumber(String personId, PhoneNumber number)
> The first is natural from an Ecore perspective, and implicitly relies
> on XMI for handling ID/IDREFs and hence is less XML-friendly. The
> second relies on an explicit id and lookup as the mechanism for
> finding the correct Person object (on the server) and more directly
> models the SOAP message XML that needs to be constructed. A
> PhoneNumber will in both cases be thought of as a struct without
> identity.
It sound to me like you'd just want to model Person with an EAttribute
for which isID is true.
>
> The advantage of using XML serialization instead of XMI serialization
> is that it is easier to work with for non-XMI-based tools, like
> soapGUI and testing tools. In addition, sometimes the XML Schema
> already exists, and the Ecore model is "just" a more structured model
> of the data. The downside is that it requires more manual work when
> modeling the operations and constructing the XML (I plan to use
> Javascript and E4X as described in
> http://www.ibm.com/developerworks/webservices/library/ws-aja x1/ for
> the latter).
I'm not particularly fond of XMI serializations. You could just avoid
them. If you want a specific serialization format, you might take the
following approach. Export your model to an XML Schema, change that
schema to suit any serialization details you want, and then reimport
your Ecore mode from that XML Schema. Then be sure to use the generated
resource factory for serializing instances to respect that XML Schema...
>
> Hallvard


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML Schema vs. XML Schema for XMI [message #418785 is a reply to message #418781] Tue, 29 April 2008 16:39 Go to previous message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Comments below.

Ed Merks wrote:
>> Consider a phonebook case, where a Person contains PhoneNumbers. A
>> service for setting the mobile number of a Person can be modelled in
>> two ways:
>> 1) setPhoneNumber(Person person, PhoneNumber number)
>> 2) setPhoneNumber(String personId, PhoneNumber number)
>> The first is natural from an Ecore perspective, and implicitly relies
>> on XMI for handling ID/IDREFs and hence is less XML-friendly. The
>> second relies on an explicit id and lookup as the mechanism for
>> finding the correct Person object (on the server) and more directly
>> models the SOAP message XML that needs to be constructed. A
>> PhoneNumber will in both cases be thought of as a struct without
>> identity.
> It sound to me like you'd just want to model Person with an EAttribute
> for which isID is true.

In this example, yes, but in general an object may have several attributes that
are used as keys relative to a parent. An id is just a special key where the
resource is the context for resolving it. E.g. PhoneNumber may be keyed with a
role attribute of type xsd:string relative to a Person. Hence, operations
referencing a PhoneNumber need a xsd:string role parameter.

> I'm not particularly fond of XMI serializations. You could just avoid
> them. If you want a specific serialization format, you might take the
> following approach. Export your model to an XML Schema, change that
> schema to suit any serialization details you want, and then reimport
> your Ecore mode from that XML Schema. Then be sure to use the generated
> resource factory for serializing instances to respect that XML Schema...

Thank you for this suggestion! Currently, I'm avoiding code generation due to
deployment issues, but I guess your point is to make sure to use the correct
Resource implementation and code for setting load options etc.

Hallvard
Previous Topic:Required attributes missing in generated XML from EMF editor
Next Topic:Tweaking EMF PropertyDescriptors
Goto Forum:
  


Current Time: Fri May 10 13:51:14 GMT 2024

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

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

Back to the top