Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » concrete type in xsi:type instead of element name
concrete type in xsi:type instead of element name [message #657493] Thu, 03 March 2011 01:23 Go to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
I have this weird situation where i define one element of type EventProducer and a container element for it named EventDiagram where i have a reference in EventDiagram to EventProducer (0->*) called flowElements. EventProducer if of type FlowElement.

When I generate the xml from the model classes it looks like this:
<epn:EventDiagram>
<flowElements xsi:type="epn:EventProducer" id="producer1" name="producer1"/>
....
</epn:EventDiagram>

but what I am expecting it to look like is:

<epn:EventDiagram>
<epn:EventProducer" id="producer1" name="producer1"/>
....
</epn:EventDiagram>

For some reason the model is not respecting the xmlns:epn for all elements but only the root one..has anyone ran into a similar situation before? Any help is much appreciated.

Thanks.

[Updated on: Thu, 03 March 2011 01:23]

Report message to a moderator

Re: concrete type in xsi:type instead of element name [message #657497 is a reply to message #657493] Thu, 03 March 2011 01:29 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Comments below.

tsurdilo wrote:
> I have this weird situation where i define one element of type
> EventProducer and a container element for it named EventDiagram where
> i have a reference in EventDiagram to EventProducer (0->*) called
> flowElements. EventProducer if of type FlowElement.
>
> When I generate the xml from the model classes it looks like this:
> <epn:EventDiagram>
> <flowElements xsi:type="epn:EventProducer" id="producer1"
> name="producer1"/>
> ...
> </epn:EventDiagram>
>
> but what I am expecting it to look like is:
>
> <epn:EventDiagram>
> <epn:EventProducer" id="producer1" name="producer1"/>
Nested element names correspond to feature names, not to type names.
> ...
> </epn:EventDiagram>
>
> For some reason the model is not respecting the xmlns:epn for all elements
What are you expecting it to respect? Feature names are generally
unqualified, at least by default.
> but only the root one..has anyone ran into a similar situation before?
All this sounds expected...
> Any help is much appreciated.
What's the problem? If you expect your results to conform to a
particular XML style, it's best you define a schema for that XML and
generate your Ecore model from that XML Schema. And then of course its
important you use the generated resource factory for producing the
resource you use to save and load instances of your model.
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: concrete type in xsi:type instead of element name [message #657510 is a reply to message #657497] Thu, 03 March 2011 05:27 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Hi Ed, thanks for the info! I changed my approach and am creating the ecore model from a xsd. One thing I don't full understand is "Nested element names correspond to feature names, not to type names." -- how do I add a feature to an existing element with a corresponding complex type so that it is used as the name of the element? Is it using <xsd:feature .../> and is so how can I add this into for example:


<xsd:element name="myProducer" type="tMyProducer"
substitutionGroup="myElements" />
<xsd:complexType name="tMyProducer">
<xsd:complexContent>
<xsd:extension base="MyTask">
<xsd:attribute name="implementation" type="Implementation"
default="##unspecified" />
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>

Help is much appreciated.

Thanks.
Re: concrete type in xsi:type instead of element name [message #657642 is a reply to message #657510] Thu, 03 March 2011 14:53 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
shameless bump Smile
Re: concrete type in xsi:type instead of element name [message #657651 is a reply to message #657510] Thu, 03 March 2011 15:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Comments below.

tsurdilo wrote:
> Hi Ed, thanks for the info! I changed my approach and am creating the
> ecore model from a xsd. One thing I don't full understand is "Nested
> element names correspond to feature names, not to type names." -- how
> do I add a feature to an existing element with a corresponding complex
> type so that it is used as the name of the element?
FeatureMaps...
> Is it using <xsd:feature .../> and is so how can I add this into for
> example:
>
>
> <xsd:element name="myProducer" type="tMyProducer"
> substitutionGroup="myElements" />
Where do you use myElements?
> <xsd:complexType name="tMyProducer">
> <xsd:complexContent>
> <xsd:extension base="MyTask">
> <xsd:attribute name="implementation" type="Implementation"
> default="##unspecified" />
> </xsd:extension>
> </xsd:complexContent>
> </xsd:complexType>
>
> Help is much appreciated.
Have a look at
http://ed-merks.blogspot.com/2007/12/winters-icy-grip.html to make
better use of substitution groups without wrecking your nice API.
>
> Thanks.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: concrete type in xsi:type instead of element name [message #657653 is a reply to message #657642] Thu, 03 March 2011 15:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
You're asking questions late in my evening. There's no need to bump it
one of my work days has gone by.

tsurdilo wrote:
> shameless bump :)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: concrete type in xsi:type instead of element name [message #657684 is a reply to message #657651] Thu, 03 March 2011 16:06 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Your article on substitution groups helped a ton. Thank you very much!
Re: concrete type in xsi:type instead of element name [message #657685 is a reply to message #657653] Thu, 03 March 2011 16:07 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Yeah sorry about the bump ..that was stupid of me
Re: concrete type in xsi:type instead of element name [message #657715 is a reply to message #657684] Thu, 03 March 2011 16:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Who says my blogs are just pretty pictures? Those are just a bonus. :-P

tsurdilo wrote:
> Your article on substitution groups helped a ton. Thank you very much!


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:UnresolvedReferenceException an ID
Next Topic:Code generation for RCP editor broken?
Goto Forum:
  


Current Time: Thu Apr 18 06:29:46 GMT 2024

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

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

Back to the top