|
Re: XSD -> Ecore, ref and attribute with same name [message #428505 is a reply to message #428502] |
Tue, 24 March 2009 12:04 |
Ed Merks Messages: 33145 Registered: July 2009 |
Senior Member |
|
|
Hauke,
Comments below.
Hauke Fuhrmann wrote:
> Hi there,
>
> I have a fixed XSD and want to write exactly the corresponding XML
> language via an EMF model.
>
> Problem is, that in XSD there may be attributes and references with the
> same name, as here:
>
> <xs:element name="entity">
> <xs:complexType>
> <xs:choice maxOccurs="unbounded" minOccurs="0">
> <xs:element ref="class"/>
> <xs:element ref="entity"/>
> </xs:choice>
> <xs:attribute name="class"/>
> </xs:complexType>
>
You've got to love that kind of design hey. :-(
> Hence the "class" feature is both, an attribute and an element
> reference. This is fine in XML, however Ecore renames one of them to
> "class1".
Yes, they must be unique in the end.
> Therefore saving an ecore instance to XMI, the attribute is
> also "class1" which is not valid to my initial XSD.
>
So don't save with XMI. Save with a resource created by the generated
resource factory.
> Any chance to convince EMF to store both features in the XMI resource
> with both the name "class" ?
>
The OPTION_EXTENDED_META_DATA will help a bit, but really, if you save
as XMI, it won't be valid according to the schema so don't do that. Use
a correctly configured XMLResourceImpl, like that produced by the
generated XyxResourceFactoryImpl.
> Cheers,
> Hauke
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03571 seconds