Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Editor EMF created from XML schema produce bad code
Editor EMF created from XML schema produce bad code [message #416211] Tue, 22 January 2008 12:47 Go to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
I generated my edit and editor code from my XML Schema but now when I use the editor it produce not well formed code.

It depends from my XML Schema or I have to little modify the generated model ?
Re: Editor EMF created from XML schema produce bad code [message #416212 is a reply to message #416211] Tue, 22 January 2008 13:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Andrea,

Normally, you shouldn't expect to get bad code generated unless there are
errors in your model (duplicate element or type names, etc.).

When you open the GenModel editor, does it show you validation problems?

Cheers,

Christian


Andrea wrote:

> I generated my edit and editor code from my XML Schema but now when I use
> the editor it produce not well formed code.
>
> It depends from my XML Schema or I have to little modify the generated
> model ?
Re: Editor EMF created from XML schema produce bad code [message #416213 is a reply to message #416212] Tue, 22 January 2008 13:24 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070906050503060606010108
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christian,

Maybe the problem was serialized content that didn't conform to the
schema. Obviously we need more details to answer the questions. Like
what's the specific problem. What does the schema look like? What does
the XML look like?


Christian W. Damus wrote:
> Hi, Andrea,
>
> Normally, you shouldn't expect to get bad code generated unless there are
> errors in your model (duplicate element or type names, etc.).
>
> When you open the GenModel editor, does it show you validation problems?
>
> Cheers,
>
> Christian
>
>
> Andrea wrote:
>
>
>> I generated my edit and editor code from my XML Schema but now when I use
>> the editor it produce not well formed code.
>>
>> It depends from my XML Schema or I have to little modify the generated
>> model ?
>>
>
>


--------------070906050503060606010108
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christian,<br>
<br>
Maybe the problem was serialized content that didn't conform to the
schema.&nbsp;&nbsp; Obviously we need more details to answer the questions.&nbsp; Like
what's the specific problem.&nbsp; What does the schema look like?&nbsp; What
does the XML look like?<br>
<br>
<br>
Christian W. Damus wrote:
<blockquote cite="mid:fn4po9$ije$1@build.eclipse.org" type="cite">
<pre wrap="">Hi, Andrea,

Normally, you shouldn't expect to get bad code generated unless there are
errors in your model (duplicate element or type names, etc.).

When you open the GenModel editor, does it show you validation problems?

Cheers,

Christian


Andrea wrote:

</pre>
<blockquote type="cite">
<pre wrap="">I generated my edit and editor code from my XML Schema but now when I use
the editor it produce not well formed code.

It depends from my XML Schema or I have to little modify the generated
model ?
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
</body>
</html>

--------------070906050503060606010108--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Editor EMF created from XML schema produce bad code [message #416215 is a reply to message #416211] Tue, 22 January 2008 14:02 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
------=_Part_3932_22239287.1201011146339
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I attach my XML Schema.

Everything go well.
I run my eclipse application in a new workbench
I open with wizard my Schema05 model

I see everything correctly but when I try to add child to the root
I can only add one context and one group type.

Then when I take a look to the code with the editor it is bad formed.

Example by Hand (as it should be)
<context width="297mm" height="210mm" resolution="300dpi">
<group layout="star" proximity="close" similarity="width color">
<!-- a few "static" objects -->
<object><svg:rect/></object>/>
<object><svg:circle/></object>
<!-- sources of dynamic content -->
<object source="//p[@class='offer']" priority="low">
...other....
<object>
</group>
</group>

I obtain something like (with editor)

<?xml version="1.0" encoding="UTF-8"?>
alignment.priority="1"
aspect-ratio="1"
importance.priority="1"
layout="horizontal"
<context></context>
<group/>

Is it clear ?
------=_Part_3932_22239287.1201011146339
Content-Type: application/octet-stream; name=schema0.5.xsd
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=schema0.5.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="context">
<xs:complexType>
<xs:simpleContent>
<xs:restriction base="CTcontext">
<xs:enumeration value="width"/>
<xs:enumeration value="height"/>
<xs:enumeration value="aspect-ratio"/>
<xs:enumeration value="area"/>
<xs:enumeration value="margin"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:simpleType name="SToverflow">
<xs:restriction base="xs:string">
<xs:enumeration value="repeat"/>
<xs:enumeration value="hidden"/>
<xs:enumeration value="scrollX"/>
<xs:enumeration value="scrollY"/>
<xs:enumeration value="scrollXY"/>
<xs:enumeration value="stretchX"/>
<xs:enumeration value="stretchY"/>
<xs:enumeration value="stretchXY"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="overflow" type="SToverflow" default="hidden"/>
<xs:simpleType name="STpriority">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="1"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="overflow.priority" type="STpriority" default="0"/>
<xs:element name="group">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="order" type="xs:boolean" default="false"/>
<xs:attribute name="similarity" type="STsimilarity"/>
<xs:attribute name="order.priority" type="STpriority"/>
<xs:attribute name="similarity.priority" type="STpriority"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="object" type="xs:string"/>
<xs:simpleType name="STimportance">
<xs:restriction base="xs:string">
<xs:enumeration value="high"/>
<xs:enumeration value="medium"/>
<xs:enumeration value="low"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="importance" type="STimportance"/>
<xs:attribute name="importance.priority" type="STpriority"/>
<xs:simpleType name="STsimilarity">
<xs:restriction base="xs:string">
<xs:enumeration value="width"/>
<xs:enumeration value="height"/>
<xs:enumeration value="color"/>
<xs:enumeration value="area"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="CTcontext" block="" final="" mixed="true">
<xs:simpleContent>
<xs:extension base="xs:string"/>
</xs:simpleContent>
</xs:complexType>
<xs:simpleType name="STaspect-ratio">
<xs:restriction base="xs:positiveInteger"/>
</xs:simpleType>
<xs:attribute name="aspect-ratio" type="STaspect-ratio"/>
<xs:attribute name="resolution" type="STresolution"/>
<xs:simpleType name="STresolution">
<xs:restriction base="xs:integer">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STborder">
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="border" type="STborder" default="0"/>
<xs:simpleType name="STlayout">
<xs:restriction base="xs:string">
<xs:enumeration value="one-dimensional"/>
<xs:enumeration value="two-dimensional"/>
<xs:enumeration value="horizontal"/>
<xs:enumeration value="lines"/>
<xs:enumeration value="vertical"/>
<xs:enumeration value="columns"/>
<xs:enumeration value="checked"/>
<xs:enumeration value="bordure"/>
<xs:enumeration value="cross"/>
<xs:enumeration value="saltire"/>
<xs:enumeration value="circle"/>
<xs:enumeration value="star"/>
<xs:enumeration value="rendom"/>
<xs:enumeration value="triangle"/>
<xs:enumeration value="overlap"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="layout" type="STlayout"/>
<xs:attribute name="layout.priority" type="STpriority"/>
<xs:simpleType name="STAvertical">
<xs:restriction base="xs:string">
<xs:enumeration value="above"/>
<xs:enumeration value="center"/>
<xs:enumeration value="below"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="STAhorizontal">
<xs:restriction base="xs:string">
<xs:enumeration value="left"/>
<xs:enumeration value="center"/>
<xs:enumeration value="right"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="alignment.vertical" type="STAvertical"/>
<xs:attribute name="alignment.horizontal" type="STAhorizontal"/>
<xs:attribute name="alignment.priority" type="STpriority"/>
<xs:attribute name="proximity"/>
<xs:simpleType name="STproximity">
<xs:restriction base="xs:string">
<xs:enumeration value="weak"/>
<xs:enumeration value="strong"/>
</xs:restriction>
</xs:simpleType>
<xs:attribute name="proximity.priority" type="STpriority"/>
</xs:schema>

------=_Part_3932_22239287.1201011146339--
Re: Editor EMF created from XML schema produce bad code [message #416217 is a reply to message #416215] Tue, 22 January 2008 15:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Andrea,

I only see three elements in your schema and all are root elements so I
see no possibility for nesting elements within elements for this
schema. I think your expectations might be a little off...


Andrea wrote:
> I attach my XML Schema.
>
> Everything go well.
> I run my eclipse application in a new workbench
> I open with wizard my Schema05 model
>
> I see everything correctly but when I try to add child to the root
> I can only add one context and one group type.
>
> Then when I take a look to the code with the editor it is bad formed.
>
> Example by Hand (as it should be)
> <context width="297mm" height="210mm" resolution="300dpi">
> <group layout="star" proximity="close" similarity="width color">
> <!-- a few "static" objects -->
> <object><svg:rect/></object>/>
> <object><svg:circle/></object>
> <!-- sources of dynamic content -->
> <object source="//p[@class='offer']" priority="low">
> ...other....
> <object>
> </group>
> </group>
>
> I obtain something like (with editor)
>
> <?xml version="1.0" encoding="UTF-8"?>
> alignment.priority="1"
> aspect-ratio="1"
> importance.priority="1"
> layout="horizontal"
> <context></context>
> <group/>
>
> Is it clear ?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Editor EMF created from XML schema produce bad code [message #416222 is a reply to message #416217] Tue, 22 January 2008 15:48 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
So I have to write the Schema in other way ?

Thanks...
Re: Editor EMF created from XML schema produce bad code [message #416224 is a reply to message #416222] Tue, 22 January 2008 15:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Andrea,

Yes, if you want to allow nested elements then the content model of the
complex type for the parent element must define a <sequence> with an
<element ref="..."> or <element name="..."> for the element you want to
allow to appear nested.


Andrea wrote:
> So I have to write the Schema in other way ?
>
> Thanks...
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Editor EMF created from XML schema produce bad code [message #416717 is a reply to message #416224] Thu, 14 February 2008 00:00 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Hi All,
i've now correct my schema but I have a problem in the input of properties.

Example:

In my schema I defined a property
&lt;xs:simpleType name=&quot;STcolor&quot;&gt;
&lt;xs:restriction base=&quot;xs:string&quot;&gt;
&lt;xs:length value=&quot;7&quot;/&gt;
&lt;xs:pattern value=&quot;#+\d&quot;/&gt;
&lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

but when I try to insert a value like ffffff or #ffffff in my property view for the color property the EMF tell to me:

the value 'ffffff' must be match one of {'#+\d'}

Why this ?
Some help ?
Re: Editor EMF created from XML schema produce bad code [message #416719 is a reply to message #416717] Thu, 14 February 2008 00:24 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Andrea,

I believe the regular expression is not appropriate for the restriction
you want to implement. "#+\d" only allows strings that start with # and
have one digit (0-9) as the second character.

To allow both ffffff and #ffffff (or #123456 or ABCDEF for that
matters), I would use something like "#?\w{6}". Notice that the {6}
will not allow the color to be defined with less that 6 alphanumeric
characters.

Cheers,
Marcelo

Andrea wrote:
> Hi All,
> i've now correct my schema but I have a problem in the input of properties.
>
> Example:
>
> In my schema I defined a property
> &lt;xs:simpleType name=&quot;STcolor&quot;&gt;
> &lt;xs:restriction base=&quot;xs:string&quot;&gt;
> &lt;xs:length value=&quot;7&quot;/&gt;
> &lt;xs:pattern value=&quot;#+\d&quot;/&gt;
> &lt;/xs:restriction&gt;
> &lt;/xs:simpleType&gt;
>
> but when I try to insert a value like ffffff or #ffffff in my property view for the color property the EMF tell to me:
>
> the value 'ffffff' must be match one of {'#+\d'}
>
> Why this ?
> Some help ?
Re: Editor EMF created from XML schema produce bad code [message #416722 is a reply to message #416719] Thu, 14 February 2008 11:23 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
Thanks a lot Marcelo
your suggestion solve my problem but I don't understand
why also this part of schema give the same problem:

&lt;xs:simpleType name=&quot;STresolution&quot;&gt;
&lt;xs:restriction base=&quot;xs:integer&quot;&gt;
&lt;xs:minExclusive value=&quot;0&quot;/&gt;
&lt;xs:pattern value=&quot;\w+dpi&quot;/&gt;
&lt;/xs:restriction&gt;
&lt;/xs:simpleType&gt;

The problem is the \d or the + ?
Why this pattern give me always and everywhere the same error ?
Re: Editor EMF created from XML schema produce bad code [message #416728 is a reply to message #416722] Thu, 14 February 2008 14:29 Go to previous messageGo to next message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
I solved this problem...

It was cause the xs:integer not xs:string :(

Thanks.

Now I'm ready to generate my diagram with GMF because EMF produce perfect code.
Re: Editor EMF created from XML schema produce bad code [message #416729 is a reply to message #416722] Thu, 14 February 2008 14:38 Go to previous messageGo to next message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Hi Andrea,

It seems that your regex is not the most appropriate again (although I
don't know what is the restriction you want to enforce). I would
suggest doing some research on regular expressions. They are extremely
helpful (the Eclipse search dialog, for example, supports them) so I can
guarantee that you wouldn't be wasting your time.

When I was studying them, I've used the following links a lot. You can
create a text file in Eclipse, type in some strings, and test the
patters as you study them.
http://www.regular-expressions.info/tutorial.html
http://java.sun.com/docs/books/tutorial/essential/regex/

The pattern you have here, "\w+dpi", matches any string that has one or
more alphanumeric characters followed by the 3 letters "dpi".

Cheers,
Marcelo


Andrea wrote:
> Thanks a lot Marcelo
> your suggestion solve my problem but I don't understand
> why also this part of schema give the same problem:
>
> &lt;xs:simpleType name=&quot;STresolution&quot;&gt;
> &lt;xs:restriction base=&quot;xs:integer&quot;&gt;
> &lt;xs:minExclusive value=&quot;0&quot;/&gt;
> &lt;xs:pattern value=&quot;\w+dpi&quot;/&gt;
> &lt;/xs:restriction&gt;
> &lt;/xs:simpleType&gt;
>
> The problem is the \d or the + ?
> Why this pattern give me always and everywhere the same error ?
Re: Editor EMF created from XML schema produce bad code [message #416730 is a reply to message #416728] Thu, 14 February 2008 14:38 Go to previous message
Marcelo Paternostro is currently offline Marcelo PaternostroFriend
Messages: 602
Registered: July 2009
Senior Member
Awesome ;-)

Cheers,
Marcelo

Andrea wrote:
> I solved this problem...
>
> It was cause the xs:integer not xs:string :(
>
> Thanks.
>
> Now I'm ready to generate my diagram with GMF because EMF produce perfect code.
Previous Topic:How to get the ECore internal details
Next Topic:AddCommand and undo for eOpposites of added things
Goto Forum:
  


Current Time: Sat Apr 20 04:32:31 GMT 2024

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

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

Back to the top