Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Delete an Element
Delete an Element [message #53231] Fri, 24 September 2004 23:52 Go to next message
Eclipse UserFriend
Originally posted by: gj.puredge.com

Hi,

I'm deleting an Element from an Abstract schema.

Assuming that XSDElementDeclaration "element" is not global, ie: it is
declared inside some other declaration I believe all I do is remove
the particle from the model group list:

XSDElementDeclaration element;

// Get the particle for this element
XSDParticle particle = (XSDComponent)element.getContainer();

// Get model group containing the particle
XSDModelGroup group = (XSDModelGroup)particle.getContainer();

// Remove the particle
group.getContents().remove(p);

I hope I got this one right. It seems to work okay but I'm worried I have
oversimplified this and forgotten something really important. Any comments?

Thanks
Re: Delete an Element [message #53367 is a reply to message #53231] Mon, 27 September 2004 11:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

>Hi,
>
>I'm deleting an Element from an Abstract schema.
>
>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>declared inside some other declaration I believe all I do is remove
>the particle from the model group list:
>
>XSDElementDeclaration element;
>
>// Get the particle for this element
>XSDParticle particle = (XSDComponent)element.getContainer();
>
>// Get model group containing the particle
>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>
>// Remove the particle
>group.getContents().remove(p);
>
>I hope I got this one right. It seems to work okay but I'm worried I have
>oversimplified this and forgotten something really important. Any comments?
>
>Thanks
>
>
>
>
Re: Delete an Element [message #53446 is a reply to message #53367] Mon, 27 September 2004 18:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: gj.puredge.com

Wow! Just EcoreUtil.remove(object)? That would be very cool.

In my case I have a schema loaded into a simple tree model. I keep a
reference to the schema EObject that each tree node corresponds to:

Schema: reference to XSDSchema
Elements: reference to XSDElementDeclaration (resolved)
Attributes: reference to XSDAttributeUse
Model Groups: reference to XSDModelGroup

I just do an "instanceof" to know what kind of node I'm looking at and
display the proper icon.

Does this mean I could use EcoreUtil.remove(object) to delete each of these
from the XSD model?

XSDElementDeclaration element

EcoreUtil.remove(element);

I thought that the Particle containing the Element might get left behind.

Thanks



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:cj8uio$717$2@eclipse.org...
Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

>Hi,
>
>I'm deleting an Element from an Abstract schema.
>
>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>declared inside some other declaration I believe all I do is remove
>the particle from the model group list:
>
>XSDElementDeclaration element;
>
>// Get the particle for this element
>XSDParticle particle = (XSDComponent)element.getContainer();
>
>// Get model group containing the particle
>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>
>// Remove the particle
>group.getContents().remove(p);
>
>I hope I got this one right. It seems to work okay but I'm worried I have
>oversimplified this and forgotten something really important. Any
comments?
>
>Thanks
>
>
>
>
Re: Delete an Element [message #53498 is a reply to message #53446] Mon, 27 September 2004 18:38 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------050004070004030008080504
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

EcoreUtil.remove simply breaks the parent link. It will leave the
particle or attribute use behind.


Gary J wrote:

>Wow! Just EcoreUtil.remove(object)? That would be very cool.
>
>In my case I have a schema loaded into a simple tree model. I keep a
>reference to the schema EObject that each tree node corresponds to:
>
>Schema: reference to XSDSchema
>Elements: reference to XSDElementDeclaration (resolved)
>Attributes: reference to XSDAttributeUse
>Model Groups: reference to XSDModelGroup
>
>I just do an "instanceof" to know what kind of node I'm looking at and
>display the proper icon.
>
>Does this mean I could use EcoreUtil.remove(object) to delete each of these
>from the XSD model?
>
>XSDElementDeclaration element
>
>EcoreUtil.remove(element);
>
>I thought that the Particle containing the Element might get left behind.
>
>Thanks
>
>
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:cj8uio$717$2@eclipse.org...
>Gary,
>
>That should do the trick. EcoreUtil.remove will do the same thing.
>
>
>Gary J wrote:
>
>
>
>>Hi,
>>
>>I'm deleting an Element from an Abstract schema.
>>
>>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>>declared inside some other declaration I believe all I do is remove
>>the particle from the model group list:
>>
>>XSDElementDeclaration element;
>>
>>// Get the particle for this element
>>XSDParticle particle = (XSDComponent)element.getContainer();
>>
>>// Get model group containing the particle
>>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>>
>>// Remove the particle
>>group.getContents().remove(p);
>>
>>I hope I got this one right. It seems to work okay but I'm worried I have
>>oversimplified this and forgotten something really important. Any
>>
>>
>comments?
>
>
>>Thanks
>>
>>
>>
>>
>>
>>
>
>
>
>


--------------050004070004030008080504
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gary,<br>
<br>
EcoreUtil.remove simply breaks the parent link.&nbsp; It will leave the
particle or attribute use behind. <br>
<br>
<br>
Gary J wrote:
<blockquote cite="midcj9kvl$n9v$1@eclipse.org" type="cite">
<pre wrap="">Wow! Just EcoreUtil.remove(object)? That would be very cool.

In my case I have a schema loaded into a simple tree model. I keep a
reference to the schema EObject that each tree node corresponds to:

Schema: reference to XSDSchema
Elements: reference to XSDElementDeclaration (resolved)
Attributes: reference to XSDAttributeUse
Model Groups: reference to XSDModelGroup

I just do an "instanceof" to know what kind of node I'm looking at and
display the proper icon.

Does this mean I could use EcoreUtil.remove(object) to delete each of these
from the XSD model?

XSDElementDeclaration element

EcoreUtil.remove(element);

I thought that the Particle containing the Element might get left behind.

Thanks



"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:cj8uio$717$2@eclipse.org">news:cj8uio$717$2@eclipse.org</a>...
Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I'm deleting an Element from an Abstract schema.

Assuming that XSDElementDeclaration "element" is not global, ie: it is
declared inside some other declaration I believe all I do is remove
the particle from the model group list:

XSDElementDeclaration element;

// Get the particle for this element
XSDParticle particle = (XSDComponent)element.getContainer();

// Get model group containing the particle
XSDModelGroup group = (XSDModelGroup)particle.getContainer();

// Remove the particle
group.getContents().remove(p);

I hope I got this one right. It seems to work okay but I'm worried I have
oversimplified this and forgotten something really important. Any
</pre>
</blockquote>
<pre wrap=""><!---->comments?
</pre>
<blockquote type="cite">
<pre wrap="">Thanks




</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------050004070004030008080504--
Re: Delete an Element [message #591737 is a reply to message #53231] Mon, 27 September 2004 11:50 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

>Hi,
>
>I'm deleting an Element from an Abstract schema.
>
>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>declared inside some other declaration I believe all I do is remove
>the particle from the model group list:
>
>XSDElementDeclaration element;
>
>// Get the particle for this element
>XSDParticle particle = (XSDComponent)element.getContainer();
>
>// Get model group containing the particle
>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>
>// Remove the particle
>group.getContents().remove(p);
>
>I hope I got this one right. It seems to work okay but I'm worried I have
>oversimplified this and forgotten something really important. Any comments?
>
>Thanks
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Delete an Element [message #591789 is a reply to message #53367] Mon, 27 September 2004 18:13 Go to previous message
Gary J is currently offline Gary JFriend
Messages: 61
Registered: July 2009
Member
Wow! Just EcoreUtil.remove(object)? That would be very cool.

In my case I have a schema loaded into a simple tree model. I keep a
reference to the schema EObject that each tree node corresponds to:

Schema: reference to XSDSchema
Elements: reference to XSDElementDeclaration (resolved)
Attributes: reference to XSDAttributeUse
Model Groups: reference to XSDModelGroup

I just do an "instanceof" to know what kind of node I'm looking at and
display the proper icon.

Does this mean I could use EcoreUtil.remove(object) to delete each of these
from the XSD model?

XSDElementDeclaration element

EcoreUtil.remove(element);

I thought that the Particle containing the Element might get left behind.

Thanks



"Ed Merks" <merks@ca.ibm.com> wrote in message
news:cj8uio$717$2@eclipse.org...
Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

>Hi,
>
>I'm deleting an Element from an Abstract schema.
>
>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>declared inside some other declaration I believe all I do is remove
>the particle from the model group list:
>
>XSDElementDeclaration element;
>
>// Get the particle for this element
>XSDParticle particle = (XSDComponent)element.getContainer();
>
>// Get model group containing the particle
>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>
>// Remove the particle
>group.getContents().remove(p);
>
>I hope I got this one right. It seems to work okay but I'm worried I have
>oversimplified this and forgotten something really important. Any
comments?
>
>Thanks
>
>
>
>
Re: Delete an Element [message #591824 is a reply to message #53446] Mon, 27 September 2004 18:38 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050004070004030008080504
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Gary,

EcoreUtil.remove simply breaks the parent link. It will leave the
particle or attribute use behind.


Gary J wrote:

>Wow! Just EcoreUtil.remove(object)? That would be very cool.
>
>In my case I have a schema loaded into a simple tree model. I keep a
>reference to the schema EObject that each tree node corresponds to:
>
>Schema: reference to XSDSchema
>Elements: reference to XSDElementDeclaration (resolved)
>Attributes: reference to XSDAttributeUse
>Model Groups: reference to XSDModelGroup
>
>I just do an "instanceof" to know what kind of node I'm looking at and
>display the proper icon.
>
>Does this mean I could use EcoreUtil.remove(object) to delete each of these
>from the XSD model?
>
>XSDElementDeclaration element
>
>EcoreUtil.remove(element);
>
>I thought that the Particle containing the Element might get left behind.
>
>Thanks
>
>
>
>"Ed Merks" <merks@ca.ibm.com> wrote in message
>news:cj8uio$717$2@eclipse.org...
>Gary,
>
>That should do the trick. EcoreUtil.remove will do the same thing.
>
>
>Gary J wrote:
>
>
>
>>Hi,
>>
>>I'm deleting an Element from an Abstract schema.
>>
>>Assuming that XSDElementDeclaration "element" is not global, ie: it is
>>declared inside some other declaration I believe all I do is remove
>>the particle from the model group list:
>>
>>XSDElementDeclaration element;
>>
>>// Get the particle for this element
>>XSDParticle particle = (XSDComponent)element.getContainer();
>>
>>// Get model group containing the particle
>>XSDModelGroup group = (XSDModelGroup)particle.getContainer();
>>
>>// Remove the particle
>>group.getContents().remove(p);
>>
>>I hope I got this one right. It seems to work okay but I'm worried I have
>>oversimplified this and forgotten something really important. Any
>>
>>
>comments?
>
>
>>Thanks
>>
>>
>>
>>
>>
>>
>
>
>
>


--------------050004070004030008080504
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Gary,<br>
<br>
EcoreUtil.remove simply breaks the parent link.&nbsp; It will leave the
particle or attribute use behind. <br>
<br>
<br>
Gary J wrote:
<blockquote cite="midcj9kvl$n9v$1@eclipse.org" type="cite">
<pre wrap="">Wow! Just EcoreUtil.remove(object)? That would be very cool.

In my case I have a schema loaded into a simple tree model. I keep a
reference to the schema EObject that each tree node corresponds to:

Schema: reference to XSDSchema
Elements: reference to XSDElementDeclaration (resolved)
Attributes: reference to XSDAttributeUse
Model Groups: reference to XSDModelGroup

I just do an "instanceof" to know what kind of node I'm looking at and
display the proper icon.

Does this mean I could use EcoreUtil.remove(object) to delete each of these
from the XSD model?

XSDElementDeclaration element

EcoreUtil.remove(element);

I thought that the Particle containing the Element might get left behind.

Thanks



"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:merks@ca.ibm.com">&lt;merks@ca.ibm.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:cj8uio$717$2@eclipse.org">news:cj8uio$717$2@eclipse.org</a>...
Gary,

That should do the trick. EcoreUtil.remove will do the same thing.


Gary J wrote:

</pre>
<blockquote type="cite">
<pre wrap="">Hi,

I'm deleting an Element from an Abstract schema.

Assuming that XSDElementDeclaration "element" is not global, ie: it is
declared inside some other declaration I believe all I do is remove
the particle from the model group list:

XSDElementDeclaration element;

// Get the particle for this element
XSDParticle particle = (XSDComponent)element.getContainer();

// Get model group containing the particle
XSDModelGroup group = (XSDModelGroup)particle.getContainer();

// Remove the particle
group.getContents().remove(p);

I hope I got this one right. It seems to work okay but I'm worried I have
oversimplified this and forgotten something really important. Any
</pre>
</blockquote>
<pre wrap=""><!---->comments?
</pre>
<blockquote type="cite">
<pre wrap="">Thanks




</pre>
</blockquote>
<pre wrap=""><!---->

</pre>
</blockquote>
<br>
</body>
</html>

--------------050004070004030008080504--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Deteriming if an ElementDeclaration is a Simple or Complex Type
Next Topic:XSDSchema.resolveTypeDefinition on redefined schema
Goto Forum:
  


Current Time: Tue Apr 23 11:52:28 GMT 2024

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

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

Back to the top