|
xsi:type in EReference as Featurekind "element" wrong -
10-23-2009, 02:45 AM
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.
When you validate the xml-file with the generated korrespondin 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"
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.
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.
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
|