Derived attributes, stored in feature map (for anyAttribute support) [message #1071913] |
Sun, 21 July 2013 11:14  |
Eclipse User |
|
|
|
Hi! I have a following snippet of ECore generated from importing a fairly complex XSD Schema. I've noticed that it generated attributeWildcard feature map for XSD's anyAttribute, and every attribute in elements in inherited classes is derived from that feature map. Unfortunately, that does not work and after code generation EMF wants me to write code for each set/get method.
Changing <details key="kind" value="attributeWildcard"/> to <details key="kind" value="elementWildcard"/> solves the problem with code generation, but generated code still not works.
Leaving kind=attributeWildcard, and writing code by hand works fine.
It it supposed to be a supported feature in emf? For me it looks like a nice feature, as every known attribute will have nice accessor methods, any unknown are left in the feature map, and subclasses can reference that feature map to add more known attributes.
<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="xproc" nsURI="http://www.w3.org/ns/xproc" nsPrefix="xproc">
<eClassifiers xsi:type="ecore:EClass" name="AnyProc">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="anyProc"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="any" unique="false" upperBound="-1"
eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="elementWildcard"/>
<details key="wildcards" value="##any"/>
<details key="name" value=":0"/>
<details key="processing" value="lax"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="base" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//AnyURI">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="See http://www.w3.org/TR/xmlbase/ for
 information about this attribute."/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="base"/>
<details key="namespace" value="http://www.w3.org/XML/1998/namespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="id" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//ID"
iD="true">
<eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
<details key="documentation" value="See http://www.w3.org/TR/xml-id/ for
 information about this attribute."/>
</eAnnotations>
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="id"/>
<details key="namespace" value="http://www.w3.org/XML/1998/namespace"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="useWhen" eType="#//XPathExpression">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="use-when"/>
</eAnnotations>
</eStructuralFeatures>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="anyAttribute" unique="false"
upperBound="-1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attributeWildcard"/>
<details key="wildcards" value="##any"/>
<details key="name" value=":4"/>
<details key="processing" value="lax"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="DocumentType" eSuperTypes="#//AnyProc">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="name" value="document_._type"/>
<details key="kind" value="elementOnly"/>
</eAnnotations>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="href" lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//AnyURI"
volatile="true" transient="true" derived="true">
<eAnnotations source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
<details key="kind" value="attribute"/>
<details key="name" value="href"/>
<details key="group" value="#:4"/>
</eAnnotations>
</eStructuralFeatures>
</eClassifiers>
</ecore:EPackage>
I've attached a small example XSD which reproduces the problem. Just generate a genmodel from it, see the generated ecore, than try to generate code from it.
Attachment: example.xsd
(Size: 1.03KB, Downloaded 238 times)
[Updated on: Sun, 21 July 2013 11:29] by Moderator
|
|
|
Re: Derived attributes, stored in feature map (for anyAttribute support) [message #1071919 is a reply to message #1071913] |
Sun, 21 July 2013 11:35   |
Eclipse User |
|
|
|
Leonid,
Please open a bugzilla. This sample isn't complete because there's
nothing to for the reference to "XPath" to resolve to. Ideally you've
provide a minimal schema illustrating the problem.
On 21/07/2013 5:14 PM, Leonid Ripeynih wrote:
> Hi! I have a following snippet of ECore generated from importing a
> fairly complex XSD Schema. I've noticed that it generated
> attributeWildcard feature map for XSD's anyAttribute, and every
> attribute in elements in inherited classes is derived from that
> feature map. Unfortunately, that does not work and after code
> generation EMF wants me to write code for each set/get method.
> Changing <details key="kind" value="attributeWildcard"/> to <details
> key="kind" value="elementWildcard"/> solves the problem with code
> generation, but generated code still not works.
>
> Leaving kind=attributeWildcard, and writing code by hand works fine.
> It it supposed to be a supported feature in emf? For me it looks like
> a nice feature, as every known attribute will have nice accessor
> methods, any unknown are left in the feature map, and subclasses can
> reference that feature map to add more known attributes.
>
>
> <ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="xproc"
> nsURI="http://www.w3.org/ns/xproc" nsPrefix="xproc">
> <eClassifiers xsi:type="ecore:EClass" name="AnyProc">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="anyProc"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="any"
> unique="false" upperBound="-1"
> eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="elementWildcard"/>
> <details key="wildcards" value="##any"/>
> <details key="name" value=":0"/>
> <details key="processing" value="lax"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="base"
> eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//AnyURI">
> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
> <details key="documentation" value="See http://www.w3.org/TR/xmlbase/ for
> information about this attribute."/>
> </eAnnotations>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="base"/>
> <details key="namespace" value="http://www.w3.org/XML/1998/namespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="id"
> eType="ecore:EDataType http://www.eclipse.org/emf/2003/XMLType#//ID"
> iD="true">
> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel">
> <details key="documentation" value="See http://www.w3.org/TR/xml-id/ for
> information about this attribute."/>
> </eAnnotations>
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="id"/>
> <details key="namespace" value="http://www.w3.org/XML/1998/namespace"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="useWhen"
> eType="#//XPathExpression">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="use-when"/>
> </eAnnotations>
> </eStructuralFeatures>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="anyAttribute"
> unique="false"
> upperBound="-1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attributeWildcard"/>
> <details key="wildcards" value="##any"/>
> <details key="name" value=":4"/>
> <details key="processing" value="lax"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="DocumentType"
> eSuperTypes="#//AnyProc">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="document_._type"/>
> <details key="kind" value="elementOnly"/>
> </eAnnotations>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="href"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2003/XMLType#//AnyURI"
> volatile="true" transient="true" derived="true">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="kind" value="attribute"/>
> <details key="name" value="href"/>
> <details key="group" value="#:4"/>
> </eAnnotations>
> </eStructuralFeatures>
> </eClassifiers>
> </ecore:EPackage>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03868 seconds