Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » XML Schema Definition (XSD) » XSDConcreteComponentImpl.forceReplace throws NPE
XSDConcreteComponentImpl.forceReplace throws NPE [message #65212] Wed, 30 November 2005 08:16 Go to next message
Eclipse User
Originally posted by: ciukes.gmailDOTcomANTISPAM.fake

Hello everyone!

Problem occurs when I call:

org.eclipse.xsd.XSDSchema xmlSchema=...;
org.eclipse.emf.ecore.util.EcoreUtil.copy(xmlSchema);

I get NPE:
java.lang.NullPointerException
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceReplace(X SDConcreteComponentImpl.java:1679)
at
org.eclipse.xsd.impl.XSDModelGroupImpl.changeAttribute(XSDMo delGroupImpl.java:678)
at
org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1219)
at
org.eclipse.xsd.impl.XSDModelGroupImpl.setCompositor(XSDMode lGroupImpl.java:195)
at org.eclipse.xsd.impl.XSDModelGroupImpl.eSet(XSDModelGroupImp l.java:346)
..... more

what I see in XSDConcreteComponentImpl.forceReplace is:
1675: isReconciling = true;
1676: updatingDOM = true;
1677:
1678: XSDConcreteComponentImpl container =
(XSDConcreteComponentImpl)getContainer();
1679: container.isReconciling = true;
1680: container.updatingDOM = true;

let's see what is in called method:
public XSDConcreteComponent getContainer()
{
return
eContainer() instanceof XSDConcreteComponent ?
(XSDConcreteComponent)eContainer() :
null;
}

For me there is a bug. Since getContainer() can return null,
forceReplace have to care about container==null condition.

EcoreUtil develops copy in two steps:
1) copy of structure
2) copy of references

Because of explained above first step fails with NPE because
XSDConcreteComponentImpl don't have assigned eContainer at this stage.

What you think about that? Do you have any ideas how to create copy of
XSDSchema object? (this is must be requirement, I cannot create it from
disk file)
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65233 is a reply to message #65212] Wed, 30 November 2005 08:20 Go to previous messageGo to next message
Eclipse User
Originally posted by: ciukes.gmailDOTcomANTISPAM.fake

Marcin Maciukiewicz wrote:
>
> Hello everyone!
>
> Problem occurs when I call:
>
> org.eclipse.xsd.XSDSchema xmlSchema=...;
> org.eclipse.emf.ecore.util.EcoreUtil.copy(xmlSchema);
>
> I get NPE:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceReplace(X SDConcreteComponentImpl.java:1679)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.changeAttribute(XSDMo delGroupImpl.java:678)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1219)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.setCompositor(XSDMode lGroupImpl.java:195)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.eSet(XSDModelGroupImp l.java:346)
> .... more
>
> what I see in XSDConcreteComponentImpl.forceReplace is:
> 1675: isReconciling = true;
> 1676: updatingDOM = true;
> 1677:
> 1678: XSDConcreteComponentImpl container =
> (XSDConcreteComponentImpl)getContainer();
> 1679: container.isReconciling = true;
> 1680: container.updatingDOM = true;
>
> let's see what is in called method:
> public XSDConcreteComponent getContainer()
> {
> return
> eContainer() instanceof XSDConcreteComponent ?
> (XSDConcreteComponent)eContainer() :
> null;
> }
>
> For me there is a bug. Since getContainer() can return null,
> forceReplace have to care about container==null condition.
>
> EcoreUtil develops copy in two steps:
> 1) copy of structure
> 2) copy of references
>
> Because of explained above first step fails with NPE because
> XSDConcreteComponentImpl don't have assigned eContainer at this stage.
>
> What you think about that? Do you have any ideas how to create copy of
> XSDSchema object? (this is must be requirement, I cannot create it from
> disk file)

I have forgot most important information:) Here it is:
<?xml version="1.0" encoding="UTF-8"?>
<config version="3.0" date="1133107811900" transient="false">
<site url="platform:/base/" enabled="true" updateable="true"
policy="USER-EXCLUDE">
<feature id="org.eclipse.jdt.source" version="3.1.1"
url="features/org.eclipse.jdt.source_3.1.1/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo.source" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo.source_2.1.1/">
</feature>
<feature id="org.eclipse.sdk" version="3.1.1"
url="features/org.eclipse.sdk_3.1.1/">
</feature>
<feature id="org.eclipse.pde.source" version="3.1.1"
url="features/org.eclipse.pde.source_3.1.1/">
</feature>
<feature id="org.eclipse.rcp.source" version="3.1.1"
url="features/org.eclipse.rcp.source_3.1.1/">
</feature>
<feature id="org.eclipse.jst" version="0.7.0"
url="features/org.eclipse.jst_0.7.0/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo.doc" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo.doc_2.1.1/">
</feature>
<feature id="org.apache.wsil4j.feature" version="1.0.0"
url="features/org.apache.wsil4j.feature_1.0.0/">
</feature>
<feature id="org.eclipse.gef.examples" version="3.1.1"
plugin-identifier="org.eclipse.gef.examples.source"
url="features/org.eclipse.gef.examples_3.1.1/">
</feature>
<feature id="org.eclipse.contribution.spiderfeature" version="1.0.1"
url="features/org.eclipse.contribution.spiderfeature_1.0.1/ ">
</feature>
<feature id="org.eclipse.platform" version="3.1.1"
url="features/org.eclipse.platform_3.1.1/">
</feature>
<feature id="org.eclipse.emf.source" version="2.1.1"
url="features/org.eclipse.emf.source_2.1.1/">
</feature>
<feature id="org.eclipse.gef.source" version="3.1.1"
url="features/org.eclipse.gef.source_3.1.1/">
</feature>
<feature id="org.tigris.subversion.book" version="1.1.1"
url="features/org.tigris.subversion.book_1.1.1/">
</feature>
<feature id="org.eclipse.jdt" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.jdt_3.1.1/">
</feature>
<feature id="org.tmatesoft.javasvn" version="1.0.0"
url="features/org.tmatesoft.javasvn_1.0.0/">
</feature>
<feature id="org.eclipse.jem" version="1.1.0"
url="features/org.eclipse.jem_1.1.0/">
</feature>
<feature id="org.eclipse.gef" version="3.1.1"
url="features/org.eclipse.gef_3.1.1/">
</feature>
<feature id="org.eclipse.gef.sdk" version="3.1.1"
plugin-identifier="org.eclipse.gef.source"
url="features/org.eclipse.gef.sdk_3.1.1/">
</feature>
<feature id="org.eclipse.jem.source" version="1.1.0"
url="features/org.eclipse.jem.source_1.1.0/">
</feature>
<feature id="org.uddi4j.feature" version="2.0.3"
url="features/org.uddi4j.feature_2.0.3/">
</feature>
<feature id="org.eclipse.emf" version="2.1.1"
url="features/org.eclipse.emf_2.1.1/">
</feature>
<feature id="org.eclipse.rcp" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.rcp_3.1.1/">
</feature>
<feature id="org.eclipse.platform.source" version="3.1.1"
url="features/org.eclipse.platform.source_3.1.1/">
</feature>
<feature id="org.wsdl4j.feature" version="1.4.0"
url="features/org.wsdl4j.feature_1.4.0/">
</feature>
<feature id="org.eclipse.emf.sdk" version="2.1.1"
url="features/org.eclipse.emf.sdk_2.1.1/">
</feature>
<feature id="org.apache.axis.feature" version="1.2.1"
url="features/org.apache.axis.feature_1.2.1/">
</feature>
<feature id="org.eclipse.xsd.source" version="2.1.1"
url="features/org.eclipse.xsd.source_2.1.1/">
</feature>
<feature id="org.eclipse.xsd.doc" version="2.1.1"
url="features/org.eclipse.xsd.doc_2.1.1/">
</feature>
<feature id="org.eclipse.pde" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.pde_3.1.1/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo_2.1.1/">
</feature>
<feature id="org.eclipse.xsd" version="2.1.1"
url="features/org.eclipse.xsd_2.1.1/">
</feature>
<feature id="org.eclipse.emf.doc" version="2.1.1"
url="features/org.eclipse.emf.doc_2.1.1/">
</feature>
<feature id="org.eclipse.wst" version="0.7.0"
url="features/org.eclipse.wst_0.7.0/">
</feature>
<feature id="org.eclipse.jem.sdk" version="1.1.0"
url="features/org.eclipse.jem.sdk_1.1.0/">
</feature>
<feature id="org.tigris.subversion.subclipse" version="0.9.37"
url="features/org.tigris.subversion.subclipse_0.9.37/">
</feature>
</site>
</config>
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65254 is a reply to message #65212] Wed, 30 November 2005 08:29 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

Marcin,

Use XSDComponent.cloneConcreteComponent instead.


Marcin Maciukiewicz wrote:

>
> Hello everyone!
>
> Problem occurs when I call:
>
> org.eclipse.xsd.XSDSchema xmlSchema=...;
> org.eclipse.emf.ecore.util.EcoreUtil.copy(xmlSchema);
>
> I get NPE:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceReplace(X SDConcreteComponentImpl.java:1679)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.changeAttribute(XSDMo delGroupImpl.java:678)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1219)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.setCompositor(XSDMode lGroupImpl.java:195)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.eSet(XSDModelGroupImp l.java:346)
> .... more
>
> what I see in XSDConcreteComponentImpl.forceReplace is:
> 1675: isReconciling = true;
> 1676: updatingDOM = true;
> 1677:
> 1678: XSDConcreteComponentImpl container =
> (XSDConcreteComponentImpl)getContainer();
> 1679: container.isReconciling = true;
> 1680: container.updatingDOM = true;
>
> let's see what is in called method:
> public XSDConcreteComponent getContainer()
> {
> return
> eContainer() instanceof XSDConcreteComponent ?
> (XSDConcreteComponent)eContainer() :
> null;
> }
>
> For me there is a bug. Since getContainer() can return null,
> forceReplace have to care about container==null condition.
>
> EcoreUtil develops copy in two steps:
> 1) copy of structure
> 2) copy of references
>
> Because of explained above first step fails with NPE because
> XSDConcreteComponentImpl don't have assigned eContainer at this stage.
>
> What you think about that? Do you have any ideas how to create copy of
> XSDSchema object? (this is must be requirement, I cannot create it
> from disk file)
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65274 is a reply to message #65254] Wed, 30 November 2005 09:42 Go to previous messageGo to next message
Eclipse User
Originally posted by: ciukes.gmailDOTcomANTISPAM.fake

Ed Merks wrote:
> Marcin,
>
> Use XSDComponent.cloneConcreteComponent instead.
Would be great, but original and copy have to share DOM as I see.
In that case changes to source affects copy. I don't want this behavior.
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65295 is a reply to message #65274] Wed, 30 November 2005 10:25 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------090808060602040709010709
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Marcin,

There's a boolean to control that:

XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean
*shareDOM*);

Cloning the DOM itself is another way to get a clone.


Marcin Maciukiewicz wrote:

> Ed Merks wrote:
>
>> Marcin,
>>
>> Use XSDComponent.cloneConcreteComponent instead.
>
> Would be great, but original and copy have to share DOM as I see.
> In that case changes to source affects copy. I don't want this behavior.



--------------090808060602040709010709
Content-Type: text/html; charset=ISO-8859-1
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">
</head>
<body bgcolor="#ffffff" text="#000000">
Marcin,<br>
<br>
There's a boolean to control that:<br>
<blockquote>XSDConcreteComponent cloneConcreteComponent(boolean deep,
boolean <b>shareDOM</b>);<br>
</blockquote>
Cloning the DOM itself is another way to get a clone.<br>
<br>
<br>
Marcin Maciukiewicz wrote:
<blockquote cite="middmkdpb$ktp$1@news.eclipse.org" type="cite">Ed
Merks wrote:
<br>
<blockquote type="cite">Marcin,
<br>
<br>
Use XSDComponent.cloneConcreteComponent instead.
<br>
</blockquote>
Would be great, but original and copy have to share DOM as I see.
<br>
In that case changes to source affects copy. I don't want this
behavior.
<br>
</blockquote>
<br>
</body>
</html>

--------------090808060602040709010709--
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65316 is a reply to message #65295] Wed, 30 November 2005 10:56 Go to previous messageGo to next message
Eclipse User
Originally posted by: ciukes.gmailDOTcomANTISPAM.fake

Ed Merks wrote:
> Marcin,
>

I've got XSDSchema instance and want create deep copy of it.
New copy have to be independent from source.

with XSDComponent.cloneConcreteComponent I can only get copied XSDSchema
connected with original by shared DOM.
I don't want this.

> Cloning the DOM itself is another way to get a clone.

Can you explain me how to do that? I mean cloning DOM and creating
XSDCopy from it.
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65336 is a reply to message #65316] Wed, 30 November 2005 11:10 Go to previous messageGo to next message
Eclipse User
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000207080504050305070304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Marcin,

Have a look at XSDPrototypicalSchema:

public XSDConcreteComponent cloneComponent(XSDConcreteComponent
xsdConcreteComponent, boolean preserveDOM)
// <!-- begin-clone-component -->
{
// A component can be cloned directly or by cloning the
underlying DOM.
// By cloning the DOM you ensure that &lt;annotation>s,
non-schema namespace attributes, and formatting are preserved.
//
if (preserveDOM)
{
// If there is an element to clone.
//
Element element = xsdConcreteComponent./*{@link
XSDConcreteComponent#getElement() /*}*/getElement();
if (element != null)
{
// Clone the DOM using the DOM API, and create the same type
of component to hold it.
//
Element clonedElement = (Element)element.cloneNode(true);
XSDConcreteComponent result =
(XSDConcreteComponent)XSDFactory.eINSTANCE.create(xsdConcret eComponent.eClass());
result.setElement(clonedElement);
return result;
}
}

// Clone just the model itself so that a new DOM will need to be
created to serialize it.
//
XSDConcreteComponent result =
xsdConcreteComponent.cloneConcreteComponent(true, false);
return result;
}


Marcin Maciukiewicz wrote:

> Ed Merks wrote:
>
>> Marcin,
>>
>
> I've got XSDSchema instance and want create deep copy of it.
> New copy have to be independent from source.
>
> with XSDComponent.cloneConcreteComponent I can only get copied
> XSDSchema connected with original by shared DOM.
> I don't want this.
>
> > Cloning the DOM itself is another way to get a clone.
>
> Can you explain me how to do that? I mean cloning DOM and creating
> XSDCopy from it.
>


--------------000207080504050305070304
Content-Type: text/html; charset=ISO-8859-1
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">
</head>
<body bgcolor="#ffffff" text="#000000">
Marcin,<br>
<br>
Have a look at XSDPrototypicalSchema:<br>
<blockquote><small>&nbsp; public XSDConcreteComponent
cloneComponent(XSDConcreteComponent xsdConcreteComponent, boolean
preserveDOM)</small><br>
<small>&nbsp; // &lt;!-- begin-clone-component --&gt;</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; // A component can be cloned directly or by cloning the
underlying DOM.</small><br>
<small>&nbsp;&nbsp;&nbsp; // By cloning the DOM you ensure that
&amp;lt;annotation&gt;s, non-schema namespace attributes, and
formatting are preserved.</small><br>
<small>&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp; if (preserveDOM)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If there is an element to clone.</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element element = xsdConcreteComponent./*{@link
XSDConcreteComponent#getElement() /*}*/getElement();</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (element != null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Clone the DOM using the DOM API, and create the
same type of component to hold it.</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Element clonedElement =
(Element)element.cloneNode(true);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDConcreteComponent result =
(XSDConcreteComponent)XSDFactory.eINSTANCE.create(xsdConcret eComponent.eClass()); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; result.setElement(clonedElement);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return result;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small>&nbsp;&nbsp;&nbsp; // Clone just the model itself so that a new DOM will need
to be created to serialize it.</small><br>
<small>&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp; XSDConcreteComponent result =
xsdConcreteComponent.cloneConcreteComponent(true, false);</small><br>
<small>&nbsp;&nbsp;&nbsp; return result;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
Marcin Maciukiewicz wrote:
<blockquote cite="middmki2n$sqf$1@news.eclipse.org" type="cite">Ed
Merks wrote:
<br>
<blockquote type="cite">Marcin,
<br>
<br>
</blockquote>
<br>
I've got XSDSchema instance and want create deep copy of it.
<br>
New copy have to be independent from source.
<br>
<br>
with XSDComponent.cloneConcreteComponent I can only get copied
XSDSchema connected with original by shared DOM.
<br>
I don't want this.
<br>
<br>
&gt; Cloning the DOM itself is another way to get a clone.
<br>
<br>
Can you explain me how to do that? I mean cloning DOM and creating
XSDCopy from it.
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------000207080504050305070304--
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #65357 is a reply to message #65336] Thu, 01 December 2005 09:33 Go to previous message
Eclipse User
Originally posted by: ciukes.gmailDOTcomANTISPAM.fake

thanks for your help
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597282 is a reply to message #65212] Wed, 30 November 2005 08:20 Go to previous message
Marcin Maciukiewicz is currently offline Marcin Maciukiewicz
Messages: 5
Registered: July 2009
Junior Member
Marcin Maciukiewicz wrote:
>
> Hello everyone!
>
> Problem occurs when I call:
>
> org.eclipse.xsd.XSDSchema xmlSchema=...;
> org.eclipse.emf.ecore.util.EcoreUtil.copy(xmlSchema);
>
> I get NPE:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceReplace(X SDConcreteComponentImpl.java:1679)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.changeAttribute(XSDMo delGroupImpl.java:678)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1219)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.setCompositor(XSDMode lGroupImpl.java:195)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.eSet(XSDModelGroupImp l.java:346)
> .... more
>
> what I see in XSDConcreteComponentImpl.forceReplace is:
> 1675: isReconciling = true;
> 1676: updatingDOM = true;
> 1677:
> 1678: XSDConcreteComponentImpl container =
> (XSDConcreteComponentImpl)getContainer();
> 1679: container.isReconciling = true;
> 1680: container.updatingDOM = true;
>
> let's see what is in called method:
> public XSDConcreteComponent getContainer()
> {
> return
> eContainer() instanceof XSDConcreteComponent ?
> (XSDConcreteComponent)eContainer() :
> null;
> }
>
> For me there is a bug. Since getContainer() can return null,
> forceReplace have to care about container==null condition.
>
> EcoreUtil develops copy in two steps:
> 1) copy of structure
> 2) copy of references
>
> Because of explained above first step fails with NPE because
> XSDConcreteComponentImpl don't have assigned eContainer at this stage.
>
> What you think about that? Do you have any ideas how to create copy of
> XSDSchema object? (this is must be requirement, I cannot create it from
> disk file)

I have forgot most important information:) Here it is:
<?xml version="1.0" encoding="UTF-8"?>
<config version="3.0" date="1133107811900" transient="false">
<site url="platform:/base/" enabled="true" updateable="true"
policy="USER-EXCLUDE">
<feature id="org.eclipse.jdt.source" version="3.1.1"
url="features/org.eclipse.jdt.source_3.1.1/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo.source" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo.source_2.1.1/">
</feature>
<feature id="org.eclipse.sdk" version="3.1.1"
url="features/org.eclipse.sdk_3.1.1/">
</feature>
<feature id="org.eclipse.pde.source" version="3.1.1"
url="features/org.eclipse.pde.source_3.1.1/">
</feature>
<feature id="org.eclipse.rcp.source" version="3.1.1"
url="features/org.eclipse.rcp.source_3.1.1/">
</feature>
<feature id="org.eclipse.jst" version="0.7.0"
url="features/org.eclipse.jst_0.7.0/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo.doc" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo.doc_2.1.1/">
</feature>
<feature id="org.apache.wsil4j.feature" version="1.0.0"
url="features/org.apache.wsil4j.feature_1.0.0/">
</feature>
<feature id="org.eclipse.gef.examples" version="3.1.1"
plugin-identifier="org.eclipse.gef.examples.source"
url="features/org.eclipse.gef.examples_3.1.1/">
</feature>
<feature id="org.eclipse.contribution.spiderfeature" version="1.0.1"
url="features/org.eclipse.contribution.spiderfeature_1.0.1/ ">
</feature>
<feature id="org.eclipse.platform" version="3.1.1"
url="features/org.eclipse.platform_3.1.1/">
</feature>
<feature id="org.eclipse.emf.source" version="2.1.1"
url="features/org.eclipse.emf.source_2.1.1/">
</feature>
<feature id="org.eclipse.gef.source" version="3.1.1"
url="features/org.eclipse.gef.source_3.1.1/">
</feature>
<feature id="org.tigris.subversion.book" version="1.1.1"
url="features/org.tigris.subversion.book_1.1.1/">
</feature>
<feature id="org.eclipse.jdt" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.jdt_3.1.1/">
</feature>
<feature id="org.tmatesoft.javasvn" version="1.0.0"
url="features/org.tmatesoft.javasvn_1.0.0/">
</feature>
<feature id="org.eclipse.jem" version="1.1.0"
url="features/org.eclipse.jem_1.1.0/">
</feature>
<feature id="org.eclipse.gef" version="3.1.1"
url="features/org.eclipse.gef_3.1.1/">
</feature>
<feature id="org.eclipse.gef.sdk" version="3.1.1"
plugin-identifier="org.eclipse.gef.source"
url="features/org.eclipse.gef.sdk_3.1.1/">
</feature>
<feature id="org.eclipse.jem.source" version="1.1.0"
url="features/org.eclipse.jem.source_1.1.0/">
</feature>
<feature id="org.uddi4j.feature" version="2.0.3"
url="features/org.uddi4j.feature_2.0.3/">
</feature>
<feature id="org.eclipse.emf" version="2.1.1"
url="features/org.eclipse.emf_2.1.1/">
</feature>
<feature id="org.eclipse.rcp" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.rcp_3.1.1/">
</feature>
<feature id="org.eclipse.platform.source" version="3.1.1"
url="features/org.eclipse.platform.source_3.1.1/">
</feature>
<feature id="org.wsdl4j.feature" version="1.4.0"
url="features/org.wsdl4j.feature_1.4.0/">
</feature>
<feature id="org.eclipse.emf.sdk" version="2.1.1"
url="features/org.eclipse.emf.sdk_2.1.1/">
</feature>
<feature id="org.apache.axis.feature" version="1.2.1"
url="features/org.apache.axis.feature_1.2.1/">
</feature>
<feature id="org.eclipse.xsd.source" version="2.1.1"
url="features/org.eclipse.xsd.source_2.1.1/">
</feature>
<feature id="org.eclipse.xsd.doc" version="2.1.1"
url="features/org.eclipse.xsd.doc_2.1.1/">
</feature>
<feature id="org.eclipse.pde" version="3.1.1" plugin-version="3.1.0"
url="features/org.eclipse.pde_3.1.1/">
</feature>
<feature id="org.eclipse.emf.ecore.sdo" version="2.1.1"
url="features/org.eclipse.emf.ecore.sdo_2.1.1/">
</feature>
<feature id="org.eclipse.xsd" version="2.1.1"
url="features/org.eclipse.xsd_2.1.1/">
</feature>
<feature id="org.eclipse.emf.doc" version="2.1.1"
url="features/org.eclipse.emf.doc_2.1.1/">
</feature>
<feature id="org.eclipse.wst" version="0.7.0"
url="features/org.eclipse.wst_0.7.0/">
</feature>
<feature id="org.eclipse.jem.sdk" version="1.1.0"
url="features/org.eclipse.jem.sdk_1.1.0/">
</feature>
<feature id="org.tigris.subversion.subclipse" version="0.9.37"
url="features/org.tigris.subversion.subclipse_0.9.37/">
</feature>
</site>
</config>
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597292 is a reply to message #65212] Wed, 30 November 2005 08:29 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26011
Registered: July 2009
Senior Member
Marcin,

Use XSDComponent.cloneConcreteComponent instead.


Marcin Maciukiewicz wrote:

>
> Hello everyone!
>
> Problem occurs when I call:
>
> org.eclipse.xsd.XSDSchema xmlSchema=...;
> org.eclipse.emf.ecore.util.EcoreUtil.copy(xmlSchema);
>
> I get NPE:
> java.lang.NullPointerException
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.forceReplace(X SDConcreteComponentImpl.java:1679)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.changeAttribute(XSDMo delGroupImpl.java:678)
>
> at
> org.eclipse.xsd.impl.XSDConcreteComponentImpl.eNotify(XSDCon creteComponentImpl.java:1219)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.setCompositor(XSDMode lGroupImpl.java:195)
>
> at
> org.eclipse.xsd.impl.XSDModelGroupImpl.eSet(XSDModelGroupImp l.java:346)
> .... more
>
> what I see in XSDConcreteComponentImpl.forceReplace is:
> 1675: isReconciling = true;
> 1676: updatingDOM = true;
> 1677:
> 1678: XSDConcreteComponentImpl container =
> (XSDConcreteComponentImpl)getContainer();
> 1679: container.isReconciling = true;
> 1680: container.updatingDOM = true;
>
> let's see what is in called method:
> public XSDConcreteComponent getContainer()
> {
> return
> eContainer() instanceof XSDConcreteComponent ?
> (XSDConcreteComponent)eContainer() :
> null;
> }
>
> For me there is a bug. Since getContainer() can return null,
> forceReplace have to care about container==null condition.
>
> EcoreUtil develops copy in two steps:
> 1) copy of structure
> 2) copy of references
>
> Because of explained above first step fails with NPE because
> XSDConcreteComponentImpl don't have assigned eContainer at this stage.
>
> What you think about that? Do you have any ideas how to create copy of
> XSDSchema object? (this is must be requirement, I cannot create it
> from disk file)
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597302 is a reply to message #65254] Wed, 30 November 2005 09:42 Go to previous message
Marcin Maciukiewicz is currently offline Marcin Maciukiewicz
Messages: 5
Registered: July 2009
Junior Member
Ed Merks wrote:
> Marcin,
>
> Use XSDComponent.cloneConcreteComponent instead.
Would be great, but original and copy have to share DOM as I see.
In that case changes to source affects copy. I don't want this behavior.
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597308 is a reply to message #65274] Wed, 30 November 2005 10:25 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26011
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090808060602040709010709
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Marcin,

There's a boolean to control that:

XSDConcreteComponent cloneConcreteComponent(boolean deep, boolean
*shareDOM*);

Cloning the DOM itself is another way to get a clone.


Marcin Maciukiewicz wrote:

> Ed Merks wrote:
>
>> Marcin,
>>
>> Use XSDComponent.cloneConcreteComponent instead.
>
> Would be great, but original and copy have to share DOM as I see.
> In that case changes to source affects copy. I don't want this behavior.



--------------090808060602040709010709
Content-Type: text/html; charset=ISO-8859-1
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">
</head>
<body bgcolor="#ffffff" text="#000000">
Marcin,<br>
<br>
There's a boolean to control that:<br>
<blockquote>XSDConcreteComponent cloneConcreteComponent(boolean deep,
boolean <b>shareDOM</b>);<br>
</blockquote>
Cloning the DOM itself is another way to get a clone.<br>
<br>
<br>
Marcin Maciukiewicz wrote:
<blockquote cite="middmkdpb$ktp$1@news.eclipse.org" type="cite">Ed
Merks wrote:
<br>
<blockquote type="cite">Marcin,
<br>
<br>
Use XSDComponent.cloneConcreteComponent instead.
<br>
</blockquote>
Would be great, but original and copy have to share DOM as I see.
<br>
In that case changes to source affects copy. I don't want this
behavior.
<br>
</blockquote>
<br>
</body>
</html>

--------------090808060602040709010709--
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597321 is a reply to message #65295] Wed, 30 November 2005 10:56 Go to previous message
Marcin Maciukiewicz is currently offline Marcin Maciukiewicz
Messages: 5
Registered: July 2009
Junior Member
Ed Merks wrote:
> Marcin,
>

I've got XSDSchema instance and want create deep copy of it.
New copy have to be independent from source.

with XSDComponent.cloneConcreteComponent I can only get copied XSDSchema
connected with original by shared DOM.
I don't want this.

> Cloning the DOM itself is another way to get a clone.

Can you explain me how to do that? I mean cloning DOM and creating
XSDCopy from it.
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597325 is a reply to message #65316] Wed, 30 November 2005 11:10 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26011
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000207080504050305070304
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Marcin,

Have a look at XSDPrototypicalSchema:

public XSDConcreteComponent cloneComponent(XSDConcreteComponent
xsdConcreteComponent, boolean preserveDOM)
// <!-- begin-clone-component -->
{
// A component can be cloned directly or by cloning the
underlying DOM.
// By cloning the DOM you ensure that &lt;annotation>s,
non-schema namespace attributes, and formatting are preserved.
//
if (preserveDOM)
{
// If there is an element to clone.
//
Element element = xsdConcreteComponent./*{@link
XSDConcreteComponent#getElement() /*}*/getElement();
if (element != null)
{
// Clone the DOM using the DOM API, and create the same type
of component to hold it.
//
Element clonedElement = (Element)element.cloneNode(true);
XSDConcreteComponent result =
(XSDConcreteComponent)XSDFactory.eINSTANCE.create(xsdConcret eComponent.eClass());
result.setElement(clonedElement);
return result;
}
}

// Clone just the model itself so that a new DOM will need to be
created to serialize it.
//
XSDConcreteComponent result =
xsdConcreteComponent.cloneConcreteComponent(true, false);
return result;
}


Marcin Maciukiewicz wrote:

> Ed Merks wrote:
>
>> Marcin,
>>
>
> I've got XSDSchema instance and want create deep copy of it.
> New copy have to be independent from source.
>
> with XSDComponent.cloneConcreteComponent I can only get copied
> XSDSchema connected with original by shared DOM.
> I don't want this.
>
> > Cloning the DOM itself is another way to get a clone.
>
> Can you explain me how to do that? I mean cloning DOM and creating
> XSDCopy from it.
>


--------------000207080504050305070304
Content-Type: text/html; charset=ISO-8859-1
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">
</head>
<body bgcolor="#ffffff" text="#000000">
Marcin,<br>
<br>
Have a look at XSDPrototypicalSchema:<br>
<blockquote><small>&nbsp; public XSDConcreteComponent
cloneComponent(XSDConcreteComponent xsdConcreteComponent, boolean
preserveDOM)</small><br>
<small>&nbsp; // &lt;!-- begin-clone-component --&gt;</small><br>
<small>&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp; // A component can be cloned directly or by cloning the
underlying DOM.</small><br>
<small>&nbsp;&nbsp;&nbsp; // By cloning the DOM you ensure that
&amp;lt;annotation&gt;s, non-schema namespace attributes, and
formatting are preserved.</small><br>
<small>&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp; if (preserveDOM)</small><br>
<small>&nbsp;&nbsp;&nbsp; {</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If there is an element to clone.</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Element element = xsdConcreteComponent./*{@link
XSDConcreteComponent#getElement() /*}*/getElement();</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (element != null)</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; // Clone the DOM using the DOM API, and create the
same type of component to hold it.</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; //</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; Element clonedElement =
(Element)element.cloneNode(true);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; XSDConcreteComponent result =
(XSDConcreteComponent)XSDFactory.eINSTANCE.create(xsdConcret eComponent.eClass()); </small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; result.setElement(clonedElement);</small><br>
<small> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; return result;</small><br>
<small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</small><br>
<small>&nbsp;&nbsp;&nbsp; }</small><br>
<br>
<small>&nbsp;&nbsp;&nbsp; // Clone just the model itself so that a new DOM will need
to be created to serialize it.</small><br>
<small>&nbsp;&nbsp;&nbsp; //</small><br>
<small>&nbsp;&nbsp;&nbsp; XSDConcreteComponent result =
xsdConcreteComponent.cloneConcreteComponent(true, false);</small><br>
<small>&nbsp;&nbsp;&nbsp; return result;</small><br>
<small>&nbsp; }</small><br>
</blockquote>
<br>
Marcin Maciukiewicz wrote:
<blockquote cite="middmki2n$sqf$1@news.eclipse.org" type="cite">Ed
Merks wrote:
<br>
<blockquote type="cite">Marcin,
<br>
<br>
</blockquote>
<br>
I've got XSDSchema instance and want create deep copy of it.
<br>
New copy have to be independent from source.
<br>
<br>
with XSDComponent.cloneConcreteComponent I can only get copied
XSDSchema connected with original by shared DOM.
<br>
I don't want this.
<br>
<br>
&gt; Cloning the DOM itself is another way to get a clone.
<br>
<br>
Can you explain me how to do that? I mean cloning DOM and creating
XSDCopy from it.
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------000207080504050305070304--
Re: XSDConcreteComponentImpl.forceReplace throws NPE [message #597333 is a reply to message #65336] Thu, 01 December 2005 09:33 Go to previous message
Marcin Maciukiewicz is currently offline Marcin Maciukiewicz
Messages: 5
Registered: July 2009
Junior Member
thanks for your help
Previous Topic:XSDConcreteComponentImpl.forceReplace throws NPE
Next Topic:element namespace
Goto Forum:
  


Current Time: Thu Aug 28 03:14:22 EDT 2014

Powered by FUDForum. Page generated in 0.02242 seconds