Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Cannot set content of XSD Particle
Cannot set content of XSD Particle [message #73673] Fri, 22 February 2008 00:39 Go to next message
Eclipse UserFriend
Originally posted by: mmendonca.galdosinc.com

Hi,

I am using the eclipse XSD API to rewrite schemas. I am trying to add
particles to a model group. The added particles should be based on an
existing particle in the model group, but with a different element
content. Hence, I clone a particle, using
particle.cloneConcreteComponent(true, true). I set an existing element as
the content of this particle. However, when I do this, I get the following
exception:

java.lang.NullPointerException
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceRemov eChild(XSDConcreteComponentImpl.java:1696)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceRemoveChil d(XSDConcreteComponentImpl.java:1609)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.orphanContent( XSDConcreteComponentImpl.java:1449)
at
org.eclipse.xsd.impl.XSDParticleImpl.orphanContent(XSDPartic leImpl.java:715)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1199)
at
org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
at
org.eclipse.xsd.impl.XSDParticleImpl.setContent(XSDParticleI mpl.java:324)
at
com.galdosinc.smt.rewriter.SchemaRewriter.processModelGroup( SchemaRewriter.java:462)
at
com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou p(SchemaRewriter.java:586)
at
com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou pList(SchemaRewriter.java:411)
at
com.galdosinc.smt.rewriter.SchemaRewriter.processSchema(Sche maRewriter.java:275)
at
com.galdosinc.smt.rewriter.SchemaRewriter.rewriteSchema(Sche maRewriter.java:202)
at
com.galdosinc.smt.rewriter.SchemaRewriter.main(SchemaRewrite r.java:104)


The following is an example of my code:

XSDParticle particleClone =
(XSDParticle)particle.cloneConcreteComponent(true, true);

particleClone.setContent(modelGrpSubstitutableElement); //This is where
the error occurs

Am I using the cloneConcreteComponent method correctly. Is there something
else I need to call after particle.setContent?

Also, are there any code-examples on using the Eclipse XSD API to edit
schemas?

Any help is greatly appreciated!

Thanks,

Michael
Re: Cannot set content of XSD Particle [message #73692 is a reply to message #73673] Fri, 22 February 2008 02:04 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Michael,

I don't think you want to share the DOM with another component already
using that DOM, i.e., false for the second argument would be better.
I'm not sure why you'd clone at all if you are going to set the content
anyway, i.e, why not just create a new particle. XSDPrototypicalSchema
shows all kinds of examples for how to create things...


Michael wrote:
> Hi,
> I am using the eclipse XSD API to rewrite schemas. I am trying to add
> particles to a model group. The added particles should be based on an
> existing particle in the model group, but with a different element
> content. Hence, I clone a particle, using
> particle.cloneConcreteComponent(true, true). I set an existing element
> as the content of this particle. However, when I do this, I get the
> following exception:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceRemov eChild(XSDConcreteComponentImpl.java:1696)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceRemoveChil d(XSDConcreteComponentImpl.java:1609)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.orphanContent( XSDConcreteComponentImpl.java:1449)
>
> at
> org.eclipse.xsd.impl.XSDParticleImpl.orphanContent(XSDPartic leImpl.java:715)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1199)
>
> at
> org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
>
> at
> org.eclipse.xsd.impl.XSDParticleImpl.setContent(XSDParticleI mpl.java:324)
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processModelGroup( SchemaRewriter.java:462)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou p(SchemaRewriter.java:586)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou pList(SchemaRewriter.java:411)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processSchema(Sche maRewriter.java:275)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.rewriteSchema(Sche maRewriter.java:202)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.main(SchemaRewrite r.java:104)
>
>
> The following is an example of my code:
> XSDParticle particleClone =
> (XSDParticle)particle.cloneConcreteComponent(true, true);
>
> particleClone.setContent(modelGrpSubstitutableElement); //This is
> where the error occurs
> Am I using the cloneConcreteComponent method correctly. Is there
> something else I need to call after particle.setContent?
> Also, are there any code-examples on using the Eclipse XSD API to edit
> schemas?
> Any help is greatly appreciated!
> Thanks,
>
> Michael
>
Re: Cannot set content of XSD Particle [message #602839 is a reply to message #73673] Fri, 22 February 2008 02:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Michael,

I don't think you want to share the DOM with another component already
using that DOM, i.e., false for the second argument would be better.
I'm not sure why you'd clone at all if you are going to set the content
anyway, i.e, why not just create a new particle. XSDPrototypicalSchema
shows all kinds of examples for how to create things...


Michael wrote:
> Hi,
> I am using the eclipse XSD API to rewrite schemas. I am trying to add
> particles to a model group. The added particles should be based on an
> existing particle in the model group, but with a different element
> content. Hence, I clone a particle, using
> particle.cloneConcreteComponent(true, true). I set an existing element
> as the content of this particle. However, when I do this, I get the
> following exception:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceNiceRemov eChild(XSDConcreteComponentImpl.java:1696)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.niceRemoveChil d(XSDConcreteComponentImpl.java:1609)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.orphanContent( XSDConcreteComponentImpl.java:1449)
>
> at
> org.eclipse.xsd.impl.XSDParticleImpl.orphanContent(XSDPartic leImpl.java:715)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1199)
>
> at
> org.eclipse.emf.common.notify.impl.NotificationImpl.dispatch (NotificationImpl.java:1030)
>
> at
> org.eclipse.xsd.impl.XSDParticleImpl.setContent(XSDParticleI mpl.java:324)
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processModelGroup( SchemaRewriter.java:462)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou p(SchemaRewriter.java:586)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processElementGrou pList(SchemaRewriter.java:411)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.processSchema(Sche maRewriter.java:275)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.rewriteSchema(Sche maRewriter.java:202)
>
> at
> com.galdosinc.smt.rewriter.SchemaRewriter.main(SchemaRewrite r.java:104)
>
>
> The following is an example of my code:
> XSDParticle particleClone =
> (XSDParticle)particle.cloneConcreteComponent(true, true);
>
> particleClone.setContent(modelGrpSubstitutableElement); //This is
> where the error occurs
> Am I using the cloneConcreteComponent method correctly. Is there
> something else I need to call after particle.setContent?
> Also, are there any code-examples on using the Eclipse XSD API to edit
> schemas?
> Any help is greatly appreciated!
> Thanks,
>
> Michael
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Cannot set content of XSD Particle
Next Topic:How to reference/use the XSD Ecore model
Goto Forum:
  


Current Time: Fri Apr 26 15:06:15 GMT 2024

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

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

Back to the top