Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XML Schema and upper/lower bounds
XML Schema and upper/lower bounds [message #900031] Fri, 03 August 2012 14:10 Go to next message
Jesper Eskilson is currently offline Jesper EskilsonFriend
Messages: 134
Registered: July 2009
Senior Member
Hi,

I'm trying to write an XML schema for an existing XML file format, so
that I can load these XML files as EMF models, but I'm having problem in
getting the upper/lower bounds correct. For example:

> <xs:element name="project">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded">
> <xs:element name="fileVersion" type="xs:string"
> minOccurs="1" maxOccurs="1" />
> <xs:element name="configuration" type="configuration"
> maxOccurs="unbounded" />
> <xs:element name="group" type="group" maxOccurs="unbounded" />
> <xs:element name="file" type="file" maxOccurs="unbounded" />
> </xs:choice>
> </xs:complexType>
> </xs:element>

This results in a EClass "ProjectType" with a multivalued "fileVersion"
reference of type "EList<String>", but I would like "fileVersion" to be
an *attribute* of type String. Why isn't "maxOccurs" honored by EMF?

Regards,

--
/Jesper
Re: XML Schema and upper/lower bounds [message #900058 is a reply to message #900031] Fri, 03 August 2012 17:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Jesper,

Comments below.

On 03/08/2012 4:10 PM, Jesper Eskilson wrote:
> Hi,
>
> I'm trying to write an XML schema for an existing XML file format, so
> that I can load these XML files as EMF models, but I'm having problem
> in getting the upper/lower bounds correct. For example:
>
>> <xs:element name="project">
>> <xs:complexType>
>> <xs:choice maxOccurs="unbounded">
>> <xs:element name="fileVersion" type="xs:string"
>> minOccurs="1" maxOccurs="1" />
>> <xs:element name="configuration" type="configuration"
>> maxOccurs="unbounded" />
>> <xs:element name="group" type="group"
>> maxOccurs="unbounded" />
>> <xs:element name="file" type="file"
>> maxOccurs="unbounded" />
>> </xs:choice>
>> </xs:complexType>
>> </xs:element>
>
> This results in a EClass "ProjectType" with a multivalued
> "fileVersion" reference of type "EList<String>", but I would like
> "fileVersion" to be an *attribute* of type String.
Your schema allows an unbounded number of choices and hence there can be
an unbounded number of file version elements.
> Why isn't "maxOccurs" honored by EMF?
Why do you have an unbounded choice? Any bounds within its nested
elements are kind of meaningless from a schema point of view.
>
> Regards,
>
> --
> /Jesper


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML Schema and upper/lower bounds [message #900296 is a reply to message #900058] Mon, 06 August 2012 11:55 Go to previous messageGo to next message
Jesper Eskilson is currently offline Jesper EskilsonFriend
Messages: 134
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 08/03/2012 07:49 PM, Ed Merks wrote:
<blockquote cite="mid:jvh2uk$duk$1@xxxxxxxxe.org" type="cite">Jesper,
<br>
<br>
Comments below.
<br>
<br>
On 03/08/2012 4:10 PM, Jesper Eskilson wrote:
<br>
<blockquote type="cite">Hi,
<br>
<br>
I'm trying to write an XML schema for an existing XML file
format, so that I can load these XML files as EMF models, but
I'm having problem in getting the upper/lower bounds correct.
For example:
<br>
<br>
<blockquote type="cite">&nbsp;&nbsp;&nbsp; &lt;xs:element name="project"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:choice maxOccurs="unbounded"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="fileVersion"
type="xs:string"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; minOccurs="1" maxOccurs="1" /&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="configuration"
type="configuration"
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxOccurs="unbounded" /&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="group" type="group"
maxOccurs="unbounded" /&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="file" type="file"
maxOccurs="unbounded" /&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:choice&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt;
<br>
&nbsp;&nbsp;&nbsp; &lt;/xs:element&gt;
<br>
</blockquote>
<br>
This results in a EClass "ProjectType" with a multivalued
"fileVersion" reference of type "EList&lt;String&gt;", but I
would like "fileVersion" to be an *attribute* of type String.
<br>
</blockquote>
Your schema allows an unbounded number of choices and hence there
can be an unbounded number of file version elements.
<br>
<blockquote type="cite">Why isn't "maxOccurs" honored by EMF?
<br>
</blockquote>
Why do you have an unbounded choice?&nbsp; Any bounds within its nested
elements are kind of meaningless from a schema point of view.
<br>
<br>
</blockquote>
<br>
Maybe I'm hitting a limit of how XML schemas work. I want to be able
to specify child elements in any order *and* any multiplicity, but
maybe that is impossible. For example, I would like to allow a set
of child elements A, B, C in any order, such that A and B occurs
exactly once, but C occurs any number of times, but at least once.&nbsp;
If I fix the order of A and B I can use a sequence, but I would like
to avoid that.<br>
<br>
<div class="moz-signature">-- <br>
<p>
<span style="color: #a6a6a6; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><strong>Jesper
Eskilson</strong></span>
<span style="color: #fdb913; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><em>Development
Engineer</em></span><br>
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">IAR Systems AB<br>
Box 23051, Strandbodgatan 1<br>
SE-750 23 Uppsala, SWEDEN<br>
Phone: +46 18 16 78 00<br>
E-mail: <a href="mailto:jesper.eskilson@xxxxxxxx">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">jesper.eskilson@xxxxxxxx</span></a>
Website: <a href="http://www.iar.com">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.iar.com<br>
</span></a>
Twitter: <a href="http://www.twitter.com/iarsystems">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.twitter.com/iarsystems</span></a>
</span>
</p>
</div>
</body>
</html>
Re: XML Schema and upper/lower bounds [message #900313 is a reply to message #900296] Mon, 06 August 2012 13:01 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=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Jesper,<br>
<br>
XML Schema has &lt;any&gt; but its use is quite limited and EMF
treats it like a &lt;sequence&gt;.&nbsp; EMF's deserializer doesn't check
that element are actually in the correct order anyway, and will
write them out in the model's feature order (except where feature
maps are used).<br>
<br>
<br>
<div class="moz-cite-prefix">On 06/08/2012 1:55 PM, Jesper Eskilson
wrote:<br>
</div>
<blockquote cite="mid:jvobas$l1o$1@xxxxxxxxe.org" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 08/03/2012 07:49 PM, Ed Merks wrote:
<blockquote cite="mid:jvh2uk$duk$1@xxxxxxxxe.org" type="cite">Jesper,

<br>
<br>
Comments below. <br>
<br>
On 03/08/2012 4:10 PM, Jesper Eskilson wrote: <br>
<blockquote type="cite">Hi, <br>
<br>
I'm trying to write an XML schema for an existing XML file
format, so that I can load these XML files as EMF models, but
I'm having problem in getting the upper/lower bounds correct.
For example: <br>
<br>
<blockquote type="cite">&nbsp;&nbsp;&nbsp; &lt;xs:element name="project"&gt;
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:complexType&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:choice maxOccurs="unbounded"&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="fileVersion"
type="xs:string" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; minOccurs="1" maxOccurs="1" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="configuration"
type="configuration" <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; maxOccurs="unbounded" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="group" type="group"
maxOccurs="unbounded" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;xs:element name="file" type="file"
maxOccurs="unbounded" /&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:choice&gt; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/xs:complexType&gt; <br>
&nbsp;&nbsp;&nbsp; &lt;/xs:element&gt; <br>
</blockquote>
<br>
This results in a EClass "ProjectType" with a multivalued
"fileVersion" reference of type "EList&lt;String&gt;", but I
would like "fileVersion" to be an *attribute* of type String.
<br>
</blockquote>
Your schema allows an unbounded number of choices and hence
there can be an unbounded number of file version elements. <br>
<blockquote type="cite">Why isn't "maxOccurs" honored by EMF? <br>
</blockquote>
Why do you have an unbounded choice?&nbsp; Any bounds within its
nested elements are kind of meaningless from a schema point of
view. <br>
<br>
</blockquote>
<br>
Maybe I'm hitting a limit of how XML schemas work. I want to be
able to specify child elements in any order *and* any
multiplicity, but maybe that is impossible. For example, I would
like to allow a set of child elements A, B, C in any order, such
that A and B occurs exactly once, but C occurs any number of
times, but at least once.&nbsp; If I fix the order of A and B I can use
a sequence, but I would like to avoid that.<br>
<br>
<div class="moz-signature">-- <br>
<p> <span style="color: #a6a6a6; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><strong>Jesper
Eskilson</strong></span> <span style="color: #fdb913;
font-family: arial,helvetica,sans-serif; font-size: 10pt;"><em>Development

Engineer</em></span><br>
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">IAR Systems AB<br>
Box 23051, Strandbodgatan 1<br>
SE-750 23 Uppsala, SWEDEN<br>
Phone: +46 18 16 78 00<br>
E-mail: <a moz-do-not-send="true"
href="mailto:jesper.eskilson@xxxxxxxx"> <span
style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">jesper.eskilson@xxxxxxxx</span></a>
Website: <a moz-do-not-send="true"
href="http://www.iar.com"> <span style="color: #808080;
font-family: arial,helvetica,sans-serif; font-size:
10pt;">www.iar.com<br>
</span></a> Twitter: <a moz-do-not-send="true"
href="http://www.twitter.com/iarsystems"> <span
style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.twitter.com/iarsystems</span></a>
</span> </p>
</div>
</blockquote>
<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XML Schema and upper/lower bounds [message #900323 is a reply to message #900313] Mon, 06 August 2012 13:36 Go to previous messageGo to next message
Jesper Eskilson is currently offline Jesper EskilsonFriend
Messages: 134
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 08/06/2012 03:01 PM, Ed Merks wrote:
<blockquote cite="mid:jvof7s$sj0$1@xxxxxxxxe.org" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Jesper,<br>
<br>
XML Schema has &lt;any&gt; but its use is quite limited and EMF
treats it like a &lt;sequence&gt;.&nbsp; EMF's deserializer doesn't
check that element are actually in the correct order anyway, and
will write them out in the model's feature order (except where
feature maps are used).<br>
</blockquote>
<br>
Does this mean that even if I specify &lt;sequence&gt;, EMF will not
complain when parsing an XML file where the child element order does
not match? There is a lot of XML code out in the wild, and I want to
avoid getting validation and/or parse errors on them.<br>
<br>
<div class="moz-signature">-- <br>
<p>
<span style="color: #a6a6a6; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><strong>Jesper
Eskilson</strong></span>
<span style="color: #fdb913; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><em>Development
Engineer</em></span><br>
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">IAR Systems AB<br>
Box 23051, Strandbodgatan 1<br>
SE-750 23 Uppsala, SWEDEN<br>
Phone: +46 18 16 78 00<br>
E-mail: <a href="mailto:jesper.eskilson@xxxxxxxx">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">jesper.eskilson@xxxxxxxx</span></a>
Website: <a href="http://www.iar.com">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.iar.com<br>
</span></a>
Twitter: <a href="http://www.twitter.com/iarsystems">
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.twitter.com/iarsystems</span></a>
</span>
</p>
</div>
</body>
</html>
Re: XML Schema and upper/lower bounds [message #900339 is a reply to message #900323] Mon, 06 August 2012 14:41 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Jesper,<br>
<br>
Yes, it will not complain.<br>
<br>
<div class="moz-cite-prefix">On 06/08/2012 3:36 PM, Jesper Eskilson
wrote:<br>
</div>
<blockquote cite="mid:jvoh86$oa$1@xxxxxxxxe.org" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
On 08/06/2012 03:01 PM, Ed Merks wrote:
<blockquote cite="mid:jvof7s$sj0$1@xxxxxxxxe.org" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
Jesper,<br>
<br>
XML Schema has &lt;any&gt; but its use is quite limited and EMF
treats it like a &lt;sequence&gt;.&nbsp; EMF's deserializer doesn't
check that element are actually in the correct order anyway, and
will write them out in the model's feature order (except where
feature maps are used).<br>
</blockquote>
<br>
Does this mean that even if I specify &lt;sequence&gt;, EMF will
not complain when parsing an XML file where the child element
order does not match? There is a lot of XML code out in the wild,
and I want to avoid getting validation and/or parse errors on
them.<br>
<br>
<div class="moz-signature">-- <br>
<p> <span style="color: #a6a6a6; font-family:
arial,helvetica,sans-serif; font-size: 10pt;"><strong>Jesper
Eskilson</strong></span> <span style="color: #fdb913;
font-family: arial,helvetica,sans-serif; font-size: 10pt;"><em>Development

Engineer</em></span><br>
<span style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">IAR Systems AB<br>
Box 23051, Strandbodgatan 1<br>
SE-750 23 Uppsala, SWEDEN<br>
Phone: +46 18 16 78 00<br>
E-mail: <a moz-do-not-send="true"
href="mailto:jesper.eskilson@xxxxxxxx"> <span
style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">jesper.eskilson@xxxxxxxx</span></a>
Website: <a moz-do-not-send="true"
href="http://www.iar.com"> <span style="color: #808080;
font-family: arial,helvetica,sans-serif; font-size:
10pt;">www.iar.com<br>
</span></a> Twitter: <a moz-do-not-send="true"
href="http://www.twitter.com/iarsystems"> <span
style="color: #808080; font-family:
arial,helvetica,sans-serif; font-size: 10pt;">www.twitter.com/iarsystems</span></a>
</span> </p>
</div>
</blockquote>
<br>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Automatically validate all referenced models
Next Topic:EMF Code generation problem
Goto Forum:
  


Current Time: Thu Apr 25 09:57:25 GMT 2024

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

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

Back to the top