Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Embedded lists in xml schema
Embedded lists in xml schema [message #58755] Mon, 23 October 2006 19:57 Go to next message
Eclipse UserFriend
Originally posted by: jmprimeau.gmail.com

Hi,

I'm generating an emf model from an xsd model and would like emf to
generate interfaces that have simple accessors for list members.

For instance, in the following model, the Children element is nothing more
than a list, I don't necessarely want a full class for it, It would be
sufficient to get:


public List getChildren();
public void addChild();
public void removeChild(Object child_);

Or something along those lines...

This is also causing problems with the genarated editor, in that I do not
want to explicitely have to create a Children node, i'd like to simply
create Child and Ref nodes from the parent.

Thanks

Jean-Marc Primeau



My model looks something like this:


<element name="Parent">

<complexType>

<sequence>

<element name="Children">

<complexType>

<sequence minOccurs="0" maxOccurs="unbounded">

<choice>

<element name="Child" type="simple:ChildType"/>

<element name="Ref" type="simple:ChildType"/>

</choice>

</sequence>

</complexType>

</element>

</sequence>

</complexType>

</element>


Which would give me xml that looks something like this:


<Parent>

<Children>

<Child name="" />

<Child name="" />

<Ref path="" />

</Children>

</Parent>
Re: Embedded lists in xml schema [message #58780 is a reply to message #58755] Mon, 23 October 2006 20:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Jean-Marc,

EMF doesn't generate such things for you. You could modify the
templates to generate that if you like; the UML project does something
just like this. The addChild method could by implemented by
getChildren().add(XyzFactory.eINSTANCE.createChild()). The removeChild
method is the same as getChildren().remove(child), so I'm not sure how
that's even a convenience. I also don't understand how this impacts the
editor since generating convenience methods won't affect the editor at all.


Jean-Marc Primeau wrote:
> Hi,
> I'm generating an emf model from an xsd model and would like emf to
> generate interfaces that have simple accessors for list members.
> For instance, in the following model, the Children element is nothing
> more than a list, I don't necessarely want a full class for it, It
> would be sufficient to get:
>
>
> public List getChildren();
> public void addChild();
> public void removeChild(Object child_);
>
> Or something along those lines...
>
> This is also causing problems with the genarated editor, in that I do
> not want to explicitely have to create a Children node, i'd like to
> simply create Child and Ref nodes from the parent.
>
> Thanks
>
> Jean-Marc Primeau
>
>
>
> My model looks something like this:
>
>
> <element name="Parent">
>
> <complexType>
>
> <sequence>
>
> <element name="Children">
>
> <complexType>
>
> <sequence minOccurs="0" maxOccurs="unbounded">
>
> <choice>
>
> <element name="Child" type="simple:ChildType"/>
>
> <element name="Ref" type="simple:ChildType"/>
>
> </choice>
>
> </sequence>
>
> </complexType>
>
> </element>
>
> </sequence>
>
> </complexType>
>
> </element>
>
>
> Which would give me xml that looks something like this:
>
>
> <Parent>
>
> <Children>
> <Child name="" />
>
> <Child name="" />
>
> <Ref path="" />
>
> </Children>
>
> </Parent>
>
>
>
Re: Embedded lists in xml schema [message #59059 is a reply to message #58780] Tue, 24 October 2006 14:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jmprimeau.gmail.com

Hi Ed,
Let me state my full problem instead of just some small portion of
it, it seems that I might be heading in the wrong direction.

I'm using EMF with GMF to make a UI for the input of xml config files.
The structure of these files is well known in my shop, and is rigid, so I
must conform to them. That being said, the files are used to describe
arbitrarily deep trees where children nodes are held in some sort of
container node. For example, a list of <RunGroup> elements will be held
in a <RunGroups> and a <RunGroup> element will contain a <RunGroups>
element ....

The EMF editor does a good job of this with the tree, but is a bit
redundant in having me create the list elements myself. I'll look into
what you saif in your last post to get around this.

Now, when I try to create a GMF project, I'm having an issue, where I can
never create any nodes because the root node does not exist.

Is what I'm going at all possible? If so, are there examples that I could
be looking at?

Thanks
Jean-Marc
Re: Embedded lists in xml schema [message #59084 is a reply to message #59059] Tue, 24 October 2006 14:22 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Jean-Marc,

I think I understand. You have a complex type for RunGroups which is
really just a holder for a bunch of RunGroup instances. A RunGroup
itself has a feature of type RunGroups, and that defines a recursive
structure. But because RunGroups is an instance object, you need to
create one of those before you can create RunGroup children under it.
With the generated EMF editor, you could specialize the
collectNewChildDescriptors methods to create an new instance of
RunGroup, which already has an new instance of RunGroups under it so
that your users wouldn't have to take that explicit step. I don't think
GMF reuses the child creation commands from the item providers but
rather has a tool to create new instances, so probably you'd need to
specialize something different, but I think it should still be possible
to create an instance that's already partially populated. It's also
possible to specialize the commands that are created, i.e., you could
specialize AddCommand for RunGroup so that it allows a RunGroup to be
added as a child of a RunGroup and creates a specialized command that
creates a RunGroups holder if necessary and then actually add the child
to that instead.


Jean-Marc Primeau wrote:
> Hi Ed,
> Let me state my full problem instead of just some small portion
> of it, it seems that I might be heading in the wrong direction.
>
> I'm using EMF with GMF to make a UI for the input of xml config
> files. The structure of these files is well known in my shop, and is
> rigid, so I must conform to them. That being said, the files are used
> to describe arbitrarily deep trees where children nodes are held in
> some sort of container node. For example, a list of <RunGroup>
> elements will be held in a <RunGroups> and a <RunGroup> element will
> contain a <RunGroups> element ....
>
> The EMF editor does a good job of this with the tree, but is a bit
> redundant in having me create the list elements myself. I'll look
> into what you saif in your last post to get around this.
>
> Now, when I try to create a GMF project, I'm having an issue, where I
> can never create any nodes because the root node does not exist.
> Is what I'm going at all possible? If so, are there examples that I
> could be looking at?
>
> Thanks
> Jean-Marc
>
Re: Embedded lists in xml schema [message #594635 is a reply to message #58755] Mon, 23 October 2006 20:06 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Jean-Marc,

EMF doesn't generate such things for you. You could modify the
templates to generate that if you like; the UML project does something
just like this. The addChild method could by implemented by
getChildren().add(XyzFactory.eINSTANCE.createChild()). The removeChild
method is the same as getChildren().remove(child), so I'm not sure how
that's even a convenience. I also don't understand how this impacts the
editor since generating convenience methods won't affect the editor at all.


Jean-Marc Primeau wrote:
> Hi,
> I'm generating an emf model from an xsd model and would like emf to
> generate interfaces that have simple accessors for list members.
> For instance, in the following model, the Children element is nothing
> more than a list, I don't necessarely want a full class for it, It
> would be sufficient to get:
>
>
> public List getChildren();
> public void addChild();
> public void removeChild(Object child_);
>
> Or something along those lines...
>
> This is also causing problems with the genarated editor, in that I do
> not want to explicitely have to create a Children node, i'd like to
> simply create Child and Ref nodes from the parent.
>
> Thanks
>
> Jean-Marc Primeau
>
>
>
> My model looks something like this:
>
>
> <element name="Parent">
>
> <complexType>
>
> <sequence>
>
> <element name="Children">
>
> <complexType>
>
> <sequence minOccurs="0" maxOccurs="unbounded">
>
> <choice>
>
> <element name="Child" type="simple:ChildType"/>
>
> <element name="Ref" type="simple:ChildType"/>
>
> </choice>
>
> </sequence>
>
> </complexType>
>
> </element>
>
> </sequence>
>
> </complexType>
>
> </element>
>
>
> Which would give me xml that looks something like this:
>
>
> <Parent>
>
> <Children>
> <Child name="" />
>
> <Child name="" />
>
> <Ref path="" />
>
> </Children>
>
> </Parent>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Embedded lists in xml schema [message #594730 is a reply to message #58780] Tue, 24 October 2006 14:13 Go to previous message
Eclipse UserFriend
Originally posted by: jmprimeau.gmail.com

Hi Ed,
Let me state my full problem instead of just some small portion of
it, it seems that I might be heading in the wrong direction.

I'm using EMF with GMF to make a UI for the input of xml config files.
The structure of these files is well known in my shop, and is rigid, so I
must conform to them. That being said, the files are used to describe
arbitrarily deep trees where children nodes are held in some sort of
container node. For example, a list of <RunGroup> elements will be held
in a <RunGroups> and a <RunGroup> element will contain a <RunGroups>
element ....

The EMF editor does a good job of this with the tree, but is a bit
redundant in having me create the list elements myself. I'll look into
what you saif in your last post to get around this.

Now, when I try to create a GMF project, I'm having an issue, where I can
never create any nodes because the root node does not exist.

Is what I'm going at all possible? If so, are there examples that I could
be looking at?

Thanks
Jean-Marc
Re: Embedded lists in xml schema [message #594743 is a reply to message #59059] Tue, 24 October 2006 14:22 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Jean-Marc,

I think I understand. You have a complex type for RunGroups which is
really just a holder for a bunch of RunGroup instances. A RunGroup
itself has a feature of type RunGroups, and that defines a recursive
structure. But because RunGroups is an instance object, you need to
create one of those before you can create RunGroup children under it.
With the generated EMF editor, you could specialize the
collectNewChildDescriptors methods to create an new instance of
RunGroup, which already has an new instance of RunGroups under it so
that your users wouldn't have to take that explicit step. I don't think
GMF reuses the child creation commands from the item providers but
rather has a tool to create new instances, so probably you'd need to
specialize something different, but I think it should still be possible
to create an instance that's already partially populated. It's also
possible to specialize the commands that are created, i.e., you could
specialize AddCommand for RunGroup so that it allows a RunGroup to be
added as a child of a RunGroup and creates a specialized command that
creates a RunGroups holder if necessary and then actually add the child
to that instead.


Jean-Marc Primeau wrote:
> Hi Ed,
> Let me state my full problem instead of just some small portion
> of it, it seems that I might be heading in the wrong direction.
>
> I'm using EMF with GMF to make a UI for the input of xml config
> files. The structure of these files is well known in my shop, and is
> rigid, so I must conform to them. That being said, the files are used
> to describe arbitrarily deep trees where children nodes are held in
> some sort of container node. For example, a list of <RunGroup>
> elements will be held in a <RunGroups> and a <RunGroup> element will
> contain a <RunGroups> element ....
>
> The EMF editor does a good job of this with the tree, but is a bit
> redundant in having me create the list elements myself. I'll look
> into what you saif in your last post to get around this.
>
> Now, when I try to create a GMF project, I'm having an issue, where I
> can never create any nodes because the root node does not exist.
> Is what I'm going at all possible? If so, are there examples that I
> could be looking at?
>
> Thanks
> Jean-Marc
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Support EMF custom EDataTypes
Next Topic:ArrayIndexOutOfBoundsException when generating EMF-JDO/JPOX OR mapping
Goto Forum:
  


Current Time: Fri Apr 19 14:44:02 GMT 2024

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

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

Back to the top