|
Re: XSD to ECore generation: 'group' attribute for every 'xsd:choice' [message #1150225 is a reply to message #1149853] |
Tue, 22 October 2013 16:28 |
Ed Merks Messages: 33216 Registered: July 2009 |
Senior Member |
|
|
Roman,
Comments below.
On 22/10/2013 3:37 PM, Roman Svystun wrote:
> Say we have a following xsd:
> <?xml version="1.0" encoding="UTF-8"?>
> <xsd:schema xmlns:xsd="less that 5 posts, no links" xmlns:jxb=""
> xmlns:fn="" xmlns:xs="" xmlns:fo="">
>
> <xsd:complexType name="oauth20">
> <xsd:choice minOccurs="0" maxOccurs="unbounded">
> <xsd:element name="group" type="oauth20.group">
> </xsd:element>
> </xsd:choice>
> </xsd:complexType>
>
> <xsd:complexType name="oauth20.group">
> </xsd:complexType>
>
> <xsd:element name="oauth" type="oauth20" />
> </xsd:schema>
>
> Because it has '<xsd:choice>' and not an '<xsd:sequence>', after ecore
> generation that type has an additional structural feature:
No, it's because it's a group with a maxOccurs > 1
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="group"
> unique="false" upperBound="-1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EFeatureMapEntry">
>
> That wouldn't be that big of a problem if xsd didn't have and element
> with a name 'group'.
You can use annotations to choose the name.
> But right now it gets 'group1' name like this:
> <eStructuralFeatures xsi:type="ecore:EReference" name="group1"
> upperBound="-1"
> eType="#//Oauth20Group" volatile="true" transient="true"
> derived="true" containment="true" resolveProxies="false">
> So why do we need such a feature,
To preserve the mixed order, of the elements though this degenerate case
of a single element is odd. Why is it like this? Why not put the
multiplicities on the element....
> and how to work around this problem? Replace all xsd:choice with
> xsd:sequence?
No, but if you can eliminate a maxOccurs on a model group, that would be
good.
> Delete all EAttribues 'group' from ecore?
No.
> Any light is appreciated.
If you must haven them, you can choose the names using annotations.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: XSD to ECore generation: 'group' attribute for every 'xsd:choice' [message #1150245 is a reply to message #1150225] |
Tue, 22 October 2013 16:44 |
Roman Svystun Messages: 2 Registered: June 2013 |
Junior Member |
|
|
Thanks for the response. I've simplified xsd to reduce the noice. There's never a single element under 'xsd:choice'.
It's more like this:
<xsd:complexType name="sharedlibrary">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="fileset" type="sharedlibrary.fileset">
<xsd:annotation>
<xsd:documentation>Id of referenced Fileset</xsd:documentation>
<xsd:appinfo>
<ext:label>Fileset</ext:label>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="folder" type="sharedlibrary.folder">
<xsd:annotation>
<xsd:documentation>Id of referenced folder</xsd:documentation>
<xsd:appinfo>
<ext:label>Folder</ext:label>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="file" type="sharedlibrary.file">
<xsd:annotation>
<xsd:documentation>Id of referenced File</xsd:documentation>
<xsd:appinfo>
<ext:label>File</ext:label>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:choice>
...
and 30k lines more.
I'll try 'choose the names using annotations'. Right now all 'xsd:choice' are replaced by 'xsd:sequence' and multiplicities are on the elements.
This
EStructuralFeature feature = eObject.eClass().getEStructuralFeature(featureName);
is much better than this
EList eAllStructuralFeatures = eObject.eClass().getEAllStructuralFeatures();
for (int i = 0; i < eAllStructuralFeatures.size(); i++) {
if (featureName.equals(EcoreUtil.getAnnotation(
(EModelElement) eAllStructuralFeatures.get(i), EXTENDED_META_DATA_URI, NAME_KEY))) {
feature = (EStructuralFeature) eAllStructuralFeatures.get(i);
}
}
Thanks again.
[Updated on: Wed, 23 October 2013 09:43] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.04275 seconds