Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XSD -> Ecore, ref and attribute with same name
XSD -> Ecore, ref and attribute with same name [message #428502] Tue, 24 March 2009 11:34 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
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>

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". Therefore saving an ecore instance to XMI, the attribute is
also "class1" which is not valid to my initial XSD.

Any chance to convince EMF to store both features in the XMI resource
with both the name "class" ?

Cheers,
Hauke
Re: XSD -> Ecore, ref and attribute with same name [message #428505 is a reply to message #428502] Tue, 24 March 2009 12:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
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/
Re: XSD -> Ecore, ref and attribute with same name [message #428507 is a reply to message #428505] Tue, 24 March 2009 12:52 Go to previous message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Ed Merks schrieb:
> 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.

Thanks for that hint! Exactly what I need!
Guess I need to get your new book as the EMF help sometimes is not
sufficient...

Cheers,
Hauke
Previous Topic:[Teneo] Session.load
Next Topic:EMF Validation Framework
Goto Forum:
  


Current Time: Thu Apr 25 05:47:11 GMT 2024

Powered by FUDForum. Page generated in 0.03020 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top