|
Re: xsi:type in EReference as Featurekind "element" wrong [message #493135 is a reply to message #493114] |
Fri, 23 October 2009 10:48 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Andreas,
Comments below.
Andreas Gruenberger wrote:
> Hi,
>
> i have a problem with the eCore serization of models.
>
> I need two kinds of link representation
> 1. Multible Links as attributes (works perfect)
> 2. Multible Links as elements <-- here is the problem
> The links refere to an abstract class:
>
> eCore always sets the xsi:type of the elements to the type of the target.
> This is wrong becouse the type of the element should be anyURI (resp.
> the type of a link) and not to the type of the target.
Without a xsi:type, we'd not be able to create the right type of object
for the proxy.
>
> When you validate the xml-file with the generated corresponding schema
> you'll earn following error:
> "cvc-elt.4.3: Type 'tttest:A' is not validly derived from the type
> definition, 'anyURI', of element 'classesElement'. My.tttechtest1
> /Test1 line 8 XML Problem"
Unfortunately you can't always have your cake and eat it too. It has to
be possible to create a proxy instance so either the type must not be
abstract or a non-abstract type needs to be specified.
>
> This error in is correct and ecore writes the wrong xsi:type.
>
> When you set the "resolve proxy" for the reference to "false", the
> xsi:type is not written, but the link changes to IDREF.
Yes, because in this case no proxy is created. The ID can resolved by
the end of loading.
>
>
> here the Model:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <tttest:Main
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:tttest="www.tttech.tets/test1"
> xsi:schemaLocation="www.tttech.tets/test1 Test1.xsd ">
>
> <containingclasses xsi:type="tttest:A" name="a"
> classesAttribute="#//@containingclasses[name='a']
> #//@containingclasses[name='b']">
>
> <classesElement
> xsi:type="tttest:A">#//@containingclasses[name='a']</classesElement >
> <classesElement
> xsi:type="tttest:B">#//@containingclasses[name='b']</classesElement >
> </containingclasses>
> <containingclasses xsi:type="tttest:B" name="b"
> classesAttribute="#//@containingclasses[name='a']
> #//@containingclasses[name='b']" attrB="">
>
> <classesElement
> xsi:type="tttest:A">#//@containingclasses[name='a']</classesElement >
> <classesElement
> xsi:type="tttest:B">#//@containingclasses[name='b']</classesElement >
> </containingclasses>
> </tttest:Main>
>
>
> here the Part of the model:
>
> <eClassifiers xsi:type="ecore:EClass" name="Base" abstract="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="mixed"/>
> </eAnnotations>
>
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="name" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="classesElement" upperBound="-1"
> eType="#//Base" eKeys="#//Base/name">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="element"/>
> </eAnnotations>
> </eStructuralFeatures>
>
> <eStructuralFeatures xsi:type="ecore:EReference"
> name="classesAttribute" upperBound="-1"
> eType="#//Base" eKeys="#//Base/name">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> </eAnnotations>
>
> </eStructuralFeatures>
> </eClassifiers>
>
> Have anyone an idea how to solve this incompatible / schema invalid
> problem.
You'll need to change something. Easiest would be to make the type not
be abstract.
> My problem is that we use this xmls in two worlds (eclipse and
> outside), and I need a correct schemavalidation.
>
>
> i attach the model, the schmema and the example
>
> thanks a lot
> andreas
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Re: xsi:type in EReference as Featurekind "element" wrong [message #493205 is a reply to message #493201] |
Fri, 23 October 2009 15:39 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
--------------020002090601090705050209
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Andreas,
Neither 1 nor 2 sound so bad. Don't you end up with QNames representing
the type for 1 though? I guess those look like URIs...
Greetings from Berlin :-)
http://ed-merks.blogspot.com/2009/10/life-in-fast-lane.html
Andreas Gruenberger wrote:
> Thank you, for your very fast response,
>
> at this time i don't want to customize or influence the serialization
> of my models (to keep compatible with the all the nice tools available
> around EMF)
>
> two simple questions I have, what would you prefer, if you have this
> little problem:
> 1. put multiple links into one attribute (don't looks fine - but works)
> 2. or change back to a not abstract base class (which is also not
> beautiful)
>
> Thanks Andreas greetings from vienna
--------------020002090601090705050209
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">
Andreas,<br>
<br>
Neither 1 nor 2 sound so bad. Don't you end up with QNames representing
the type for 1 though? I guess those look like URIs...<br>
<br>
Greetings from Berlin :-)<br>
<blockquote><a
href="http://ed-merks.blogspot.com/2009/10/life-in-fast-lane.html">http://ed-merks.blogspot.com/2009/10/life-in-fast-lane.html</a><br>
</blockquote>
<br>
Andreas Gruenberger wrote:
<blockquote cite="mid:hbshf9$qad$1@build.eclipse.org" type="cite">Thank
you, for your very fast response,
<br>
<br>
at this time i don't want to customize or influence the serialization
of my models (to keep compatible with the all the nice tools available
around EMF)
<br>
<br>
two simple questions I have, what would you prefer, if you have this
little problem:
<br>
1. put multiple links into one attribute (don't looks fine - but works)
<br>
2. or change back to a not abstract base class (which is also not
beautiful)
<br>
<br>
Thanks Andreas greetings from vienna
<br>
</blockquote>
</body>
</html>
--------------020002090601090705050209--
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.02969 seconds