Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Notation validation failing valid data(Validation on a Notation gives error when it should)
Notation validation failing valid data [message #629748] Wed, 29 September 2010 13:07 Go to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Hi, I've hit a problem that I am hoping some-one can shed some light on for me. I have the following schema:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://example.com/Notation" targetNamespace="http://example.com/Notation">
    <xs:notation name="gif" public="image/gif" system="view.exe"/>
    <xs:notation name="jpeg" public="image/jpeg" system="view.exe"/>
    <xs:element name="image">
        <xs:complexType>
            <xs:attribute name="type">
                <xs:simpleType>
                    <xs:restriction base="xs:NOTATION">
                        <xs:enumeration value="gif"/>
                        <xs:enumeration value="jpeg"/>
                    </xs:restriction>
                </xs:simpleType>
            </xs:attribute>
        </xs:complexType>
    </xs:element>
</xs:schema>


I can generate the EMF classes OK, and can construct and populate in code:

ImageType createImageType = NotationFactory.eINSTANCE.createImageType();
QName name = new QName("gif");
createImageType.setType(name);


This can be saved and loaded as much as I like, giving XML as follows:

<notation:image xmlns:notation="http://example.com/Notation" type="gif"/>


However as soon as I try and validate it

Diagnostician.INSTANCE.validate(createImageType);


It will give me an error along the following lines:

The feature 'type' of 'com.example.notation.impl.ImageTypeImpl@16546ef{#//@image}' contains a bad value [The value 'gif' must be one of {'gif', 'jpeg'}


However it is of type=gif, so I'm not really sure what is going on

Thanks, Rob
Re: Notation validation failing valid data [message #629795 is a reply to message #629748] Wed, 29 September 2010 14:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30540
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080704020208090301070704
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Rob,

Comments below.


Rob wrote:
> Hi, I've hit a problem that I am hoping some-one can shed some light
> on for me. I have the following schema:
>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://example.com/Notation"
> targetNamespace="http://example.com/Notation">
> <xs:notation name="gif" public="image/gif" system="view.exe"/>
> <xs:notation name="jpeg" public="image/jpeg" system="view.exe"/>
> <xs:element name="image">
> <xs:complexType>
> <xs:attribute name="type">
> <xs:simpleType>
> <xs:restriction base="xs:NOTATION">
> <xs:enumeration value="gif"/>
> <xs:enumeration value="jpeg"/>
> </xs:restriction>
> </xs:simpleType>
> </xs:attribute>
> </xs:complexType>
> </xs:element>
> </xs:schema>
>
>
> I can generate the EMF classes OK, and can construct and populate in
> code:
>
> ImageType createImageType = NotationFactory.eINSTANCE.createImageType();
> QName name = new QName("gif");
> createImageType.setType(name);
>
>
> This can be saved and loaded as much as I like, giving XML as follows:
>
> <notation:image xmlns:notation="http://example.com/Notation" type="gif"/>
>
>
> However as soon as I try and validate it
>
> Diagnostician.INSTANCE.validate(createImageType);
>
> It will give me an error along the following lines:
>
> The feature 'type' of
> 'com.example.notation.impl.ImageTypeImpl@16546ef{#//@image}' contains
> a bad value [The value 'gif' must be one of {'gif', 'jpeg'}
>
> However it is of type=gif, so I'm not really sure what is going on
I think it should be

QName name = new QName("http://example.com/Notation", "gif");

>
> Thanks, Rob

--------------080704020208090301070704
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rob,<br>
<br>
Comments below.<br>
<br>
<br>
Rob wrote:
<blockquote cite="mid:i7vdgs$10p$1@news.eclipse.org" type="cite">Hi, 
I've hit a problem  that I am hoping some-one can shed some light on
for me.  I have the following schema:
<br>
<br>
&lt;xs:schema xmlns:xs=<a class="moz-txt-link-rfc2396E" href="http://www.w3.org/2001/XMLSchema">"http://www.w3.org/2001/XMLSchema"</a>
xmlns=<a class="moz-txt-link-rfc2396E" href="http://example.com/Notation">"http://example.com/Notation"</a>
targetNamespace=<a class="moz-txt-link-rfc2396E" href="http://example.com/Notation">"http://example.com/Notation"</a>&gt;
<br>
   &lt;xs:notation name="gif" public="image/gif" system="view.exe"/&gt;
<br>
   &lt;xs:notation name="jpeg" public="image/jpeg"
system="view.exe"/&gt;
<br>
   &lt;xs:element name="image"&gt;
<br>
       &lt;xs:complexType&gt;
<br>
           &lt;xs:attribute name="type"&gt;
<br>
               &lt;xs:simpleType&gt;
<br>
                   &lt;xs:restriction base="xs:NOTATION"&gt;
<br>
                       &lt;xs:enumeration value="gif"/&gt;
<br>
                       &lt;xs:enumeration value="jpeg"/&gt;
<br>
                   &lt;/xs:restriction&gt;
<br>
               &lt;/xs:simpleType&gt;
<br>
           &lt;/xs:attribute&gt;
<br>
       &lt;/xs:complexType&gt;
<br>
   &lt;/xs:element&gt;
<br>
&lt;/xs:schema&gt;
<br>
<br>
<br>
I can generate the EMF classes OK, and can construct and populate in
code:
<br>
<br>
ImageType createImageType =
NotationFactory.eINSTANCE.createImageType();
<br>
QName name = new QName("gif");
<br>
createImageType.setType(name);
<br>
<br>
<br>
This can be saved and loaded as much as I like, giving XML as follows:
<br>
<br>
&lt;notation:image xmlns:notation=<a class="moz-txt-link-rfc2396E" href="http://example.com/Notation">"http://example.com/Notation"</a>
type="gif"/&gt;
<br>
<br>
<br>
However as soon as I try and validate it
<br>
<br>
Diagnostician.INSTANCE.validate(createImageType);
<br>
<br>
It will give me an error along the following lines:
<br>
<br>
The feature 'type' of
'com.example.notation.impl.ImageTypeImpl@16546ef{#//@image}' contains a
bad value [The value 'gif' must be one of {'gif', 'jpeg'}
<br>
<br>
However it is of type=gif, so I'm not really sure what is going on
<br>
</blockquote>
I think it should be<br>
<blockquote>QName name = new QName(<a class="moz-txt-link-rfc2396E" href="http://example.com/Notation">"http://example.com/Notation"</a>,
"gif");<br>
</blockquote>
<blockquote cite="mid:i7vdgs$10p$1@news.eclipse.org" type="cite"><br>
Thanks, Rob
<br>
</blockquote>
</body>
</html>

--------------080704020208090301070704--
Re: Notation validation failing valid data [message #629818 is a reply to message #629748] Wed, 29 September 2010 16:00 Go to previous messageGo to next message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Hi Ed,

Thanks again for the super-quick reply. If I make the changes that you suggest and supply the namespace URI it will indeed work.

However if I was just to start with some XML, say:

<notation:image xmlns:notation="http://example.com/Notation" type="gif"/>


As detailed in the following example:

http://www.w3schools.com/Schema/el_notation.asp

Run a load on it to create the EMF representation, and then do a validate, I still get the error.

This would then lead me to a situation where I load in valid XML for the schema, but can then not validate the EMF that is generated.

I would appreciate any further help you can supply on this.

Thanks, Rob
Re: Notation validation failing valid data [message #629827 is a reply to message #629818] Wed, 29 September 2010 16:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30540
Registered: July 2009
Senior Member
Rob,

Comments below.

Rob wrote:
> Hi Ed,
>
> Thanks again for the super-quick reply. If I make the changes that
> you suggest and supply the namespace URI it will indeed work.
>
> However if I was just to start with some XML, say:
>
> <notation:image xmlns:notation="http://example.com/Notation" type="gif"/>
Shouldn't this be type="notation:gif"?
>
>
> As detailed in the following example:
>
> http://www.w3schools.com/Schema/el_notation.asp
In there they show

<image type="gif"></image>

but they don't show the xmlns declaration that's needed to conform to
the schema. I think it should be

<image xmlns="http://example.com/Notation" type="gif"></image>

and I thin kin that case, the QName value for "gif" is implicitly
qualified with the namespace for Notation as opposed to the explicit
qualification I showed up above.
>
> Run a load on it to create the EMF representation, and then do a
> validate, I still get the error.
>
> This would then lead me to a situation where I load in valid XML for
> the schema, but can then not validate the EMF that is generated.
Not really. Despite assertions about XML being simple, the handling of
namespace qualification seems to be one of those things that few people
understand well...
>
> I would appreciate any further help you can supply on this.
>
> Thanks, Rob
>
Re: Notation validation failing valid data [message #631184 is a reply to message #629748] Wed, 06 October 2010 13:59 Go to previous message
Rob Mising name is currently offline Rob Mising nameFriend
Messages: 118
Registered: July 2010
Senior Member
Sorry for the delay, thank you for the clarification
Previous Topic:Questions about EOperations
Next Topic:Loading different models with same namespace
Goto Forum:
  


Current Time: Mon Oct 14 11:32:14 GMT 2019

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

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

Back to the top