Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSDEcoreBuilder, Validation
XSDEcoreBuilder, Validation [message #905456] Thu, 30 August 2012 12:18 Go to next message
Eclipse UserFriend
Hello,

I'm using XSDEcoreBuilder load an XSD schema as Ecore meta model.
In the schema there is the following type:

<xs:complexType name="myType">
<xs:complexContent>
<xs:extension base="myOtherType">
<xs:choice>
<xs:element name="e1" type="e1" minOccurs="1" maxOccurs="1"/>
<xs:element name="e2" type="e2" minOccurs="1" maxOccurs="1"/>
</xs:choice>
</xs:extension>
</xs:complexContent>
</xs:complexType>

By some automated process I create a model according to this meta model.
A flaw in that generation caused an object of myType to be created which
does neither contain an e1 or e2 element. I should say this is a model
violation, but

status = Diagnostician.INSTANCE.validate(o);

did not complain but returned Diagnostic.OK! Why is that? I tried to
apply the information in "XML Schema to Ecore Mapping" (2004) but could
not find the "exclusion" annotation in the generated model. I'm on
Eclipse 4.2.

After saving the resource, the XML output looked like this:

<myType/> <------ invalid!
<myType>
<e1/>
</myType>
<myType>
<e2/>
</myType>

An external XSD validator emitted a warning about this.

TIA
Marius
Re: XSDEcoreBuilder, Validation [message #905460 is a reply to message #905456] Thu, 30 August 2012 12:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Marius,<br>
<br>
Comments below.<br>
<br>
<div class="moz-cite-prefix">On 30/08/2012 2:18 PM, Marius Gröger
wrote:<br>
</div>
<blockquote cite="mid:k1nlms$f1b$1@xxxxxxxxe.org" type="cite">
<pre wrap="">Hello,

I'm using XSDEcoreBuilder load an XSD schema as Ecore meta model.
In the schema there is the following type:

&lt;xs:complexType name="myType"&gt;
&lt;xs:complexContent&gt;
&lt;xs:extension base="myOtherType"&gt;
&lt;xs:choice&gt;
&lt;xs:element name="e1" type="e1" minOccurs="1" maxOccurs="1"/&gt;
&lt;xs:element name="e2" type="e2" minOccurs="1" maxOccurs="1"/&gt;
&lt;/xs:choice&gt;
&lt;/xs:extension&gt;
&lt;/xs:complexContent&gt;
&lt;/xs:complexType&gt;

By some automated process I create a model according to this meta model.
A flaw in that generation caused an object of myType to be created which
does neither contain an e1 or e2 element. I should say this is a model
violation, but

status = Diagnostician.INSTANCE.validate(o);

did not complain but returned Diagnostic.OK! Why is that?</pre>
</blockquote>
Ecore's content model isn't as rich as XML Schema's content model. 
There's no ability in an EClass to express that one of two features
should be populated but not both at once.  I.e., there's nothing
like &lt;choice&gt; in Ecore.  And of course the constraints you can
achieve with complicated particle structure in XML Schema are in
general even more complex.  We'd need to record the entire XML
Schema particle structure to try to enforce such constraints.  I
looked at how to do that many years ago:<br>
<blockquote><a
href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210">https://bugs.eclipse.org/bugs/show_bug.cgi?id=51210</a><br>
</blockquote>
<br>
<blockquote cite="mid:k1nlms$f1b$1@xxxxxxxxe.org" type="cite">
<pre wrap=""> I tried to
apply the information in "XML Schema to Ecore Mapping" (2004) but could
not find the "exclusion" annotation in the generated model.</pre>
</blockquote>
There isn't one.<br>
<blockquote cite="mid:k1nlms$f1b$1@xxxxxxxxe.org" type="cite">
<pre wrap=""> I'm on
Eclipse 4.2.

After saving the resource, the XML output looked like this:

&lt;myType/&gt; &lt;------ invalid!
&lt;myType&gt;
&lt;e1/&gt;
&lt;/myType&gt;
&lt;myType&gt;
&lt;e2/&gt;
&lt;/myType&gt;

An external XSD validator emitted a warning about this.</pre>
</blockquote>
At this point, the best you can do declare a constraint on the
EClass and implement it by hand.<br>
<blockquote cite="mid:k1nlms$f1b$1@xxxxxxxxe.org" type="cite">
<pre wrap="">

TIA
Marius

</pre>
</blockquote>
<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XSDEcoreBuilder, Validation [message #905467 is a reply to message #905460] Thu, 30 August 2012 12:37 Go to previous message
Eclipse UserFriend
Hello Ed,

thanks for the quick response. Seems like I was hunting a ghost.

On 30.08.2012 14:24, Ed Merks wrote:
>> I tried to
>> apply the information in "XML Schema to Ecore Mapping" (2004) but could
>> not find the "exclusion" annotation in the generated model.
> There isn't one.

I think I missed the little hint "Note: implementation of this is
TBD"... :-)

> At this point, the best you can do declare a constraint on the EClass
> and implement it by hand.

All right then. For now we run a full blown XSD validator on the XML
output, so I think we're fine.

Regards
Marius
Previous Topic:Programatically select Item in Editor in different window
Next Topic:[CDO] CDO Workspace fetches proxy elements
Goto Forum:
  


Current Time: Thu Apr 25 12:34:27 GMT 2024

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

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

Back to the top