Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to use XMLResource.load(Node node, ...) to load an Ecore model
How to use XMLResource.load(Node node, ...) to load an Ecore model [message #420440] Mon, 30 June 2008 15:43 Go to next message
Eclipse UserFriend
Originally posted by: udaykabe.hotmail.com

I have imported a WSDL file to create an EMF ecore/genmodel. Now I am
trying to generate EMF EObjcets from the body of a SOAP response by using
the load(Node node, ...) method of the generated XMLProcessor subclass.
Here is how I structure the code (sorry for the horrible formatting):

DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();

documentBuilderFactory.setNamespaceAware(true);

DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();

Document doc = documentBuilder.newDocument();

Message msg = call.getResponseMessage();

SOAPBody body = msg.getSOAPBody();

NodeList nodes = body.getChildNodes();

for (int i = 0; i < nodes.getLength(); i++) {

Node node = doc.importNode(nodes.item(i), true);

doc.appendChild(node);

}

// the processor is the generated XMLProcessor subclass

resource = processor.load(doc, null);

Unfortunately I get the exception shown below (I can load the same XML if
it is in a file that is opened by the generated editor). Can anyone shed
some light on this problem or suggest a better way of doing this.

Thank you in advance.

Uday

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
'GetZIPCodeInfoResponse' not found. (xml, -1, -1)

at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:422)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:606)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResou rceImpl.java:577)

at org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcesso r.java:268)

at
ws.kabe.strikeiron.ui.views.ZipCodeValidator.earlyStartup(Zi pCodeValidator.java:102)

at
org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup (EarlyStartupRunnable.java:87)

at
org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartu pRunnable.java:66)

at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)

at org.eclipse.ui.internal.Workbench$20.run(Workbench.java:1759 )

at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
'GetZIPCodeInfoResponse' not found. (xml, -1, -1)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1739)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1703)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1647)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot (XMLHandler.java:1229)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1157)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:528)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:517)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:404)

.... 9 more
Re: How to use XMLResource.load(Node node, ...) to load an Ecore model [message #420448 is a reply to message #420440] Mon, 30 June 2008 16:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Uday,

Comments below.

Uday Kabe wrote:
> I have imported a WSDL file to create an EMF ecore/genmodel. Now I am
> trying to generate EMF EObjcets from the body of a SOAP response by using
> the load(Node node, ...) method of the generated XMLProcessor subclass.
> Here is how I structure the code (sorry for the horrible formatting):
>
> DocumentBuilderFactory documentBuilderFactory =
> DocumentBuilderFactory.newInstance();
>
> documentBuilderFactory.setNamespaceAware(true);
>
> DocumentBuilder documentBuilder =
> documentBuilderFactory.newDocumentBuilder();
>
> Document doc = documentBuilder.newDocument();
>
> Message msg = call.getResponseMessage();
>
> SOAPBody body = msg.getSOAPBody();
>
> NodeList nodes = body.getChildNodes();
>
> for (int i = 0; i < nodes.getLength(); i++) {
>
> Node node = doc.importNode(nodes.item(i), true);
>
> doc.appendChild(node);
>
> }
>
I thought a document was only allowed to have one child...
> // the processor is the generated XMLProcessor subclass
>
> resource = processor.load(doc, null);
>
> Unfortunately I get the exception shown below (I can load the same XML if
> it is in a file that is opened by the generated editor). Can anyone shed
> some light on this problem or suggest a better way of doing this.
>
It's hard to say without seeing what the XML looks like. You've tried
serializing the DOM to see if it looks correct?
> Thank you in advance.
>
> Uday
>
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:422)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:606)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResou rceImpl.java:577)
>
> at org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcesso r.java:268)
>
> at
> ws.kabe.strikeiron.ui.views.ZipCodeValidator.earlyStartup(Zi pCodeValidator.java:102)
>
> at
> org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup (EarlyStartupRunnable.java:87)
>
> at
> org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartu pRunnable.java:66)
>
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>
> at org.eclipse.ui.internal.Workbench$20.run(Workbench.java:1759 )
>
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
>
> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1739)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1703)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1647)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot (XMLHandler.java:1229)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1157)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:528)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:517)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:404)
>
> ... 9 more
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to use XMLResource.load(Node node, ...) to load an Ecore model [message #420452 is a reply to message #420448] Mon, 30 June 2008 17:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: udaykabe.hotmail.com

Thanks Ed. Nice to "talk" to you again.

Actually there is only one child element. You can view the serialized DOM
document in the attached file.
I am basically trying to marry Apache Axis (which is used by WTP tooling to
generate the Web service client code) to EMF. Apache Axis handles the web
service SOAP-based interaction. I then try to create an instance model from
the response message.
The attached file, My3.wslite, contains the response body. When I import
the attached wsdl
file( http://wslite.strikeiron.com/zipcodeinfolite01/ZIPCodeInfoLi te.asmx?WSDL),
the importer creates wslite.ecore with NsPrefix set to "wslite" and NsURI
set to http://www.wslite.strikeiron.com/wslite.ecore. I manually set the
prefix to be empty and the nsuri to http://www.wslite.strikeiron.com. I
then generated the code. I also added a generated_package extension for
http://www.wslite.strikeiron.com and an extension_parser extension for
"wslite". By doing this, I am trying to match the namespace and prefix on
the response. I have also overridden the makeDefaultHandler() method of the
generates ResourceImpl as follows:

/* (non-Javadoc)

* @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#createXMLLoad ()

*/

protected XMLLoad createXMLLoad() {

return new XMLLoadImpl(createXMLHelper()) {

protected DefaultHandler makeDefaultHandler() {

return new SAXXMLHandler(resource, helper, options) {

protected EPackage handleMissingPackage(String uriString) {

return WslitePackage.eINSTANCE;

}

};

}

};

}

The genereated editor opens the attached file with the wslite extension
without a problem. I just can't get the "same" thing to load(Node, ...)
via the XMLProcessor subclass.

Thanks.

Uday



"Ed Merks" <Ed.Merks@gmail.com> wrote in message
news:g4b1qo$29s$1@build.eclipse.org...
> Uday,
>
> Comments below.
>
> Uday Kabe wrote:
>> I have imported a WSDL file to create an EMF ecore/genmodel. Now I am
>> trying to generate EMF EObjcets from the body of a SOAP response by using
>> the load(Node node, ...) method of the generated XMLProcessor subclass.
>> Here is how I structure the code (sorry for the horrible formatting):
>>
>> DocumentBuilderFactory documentBuilderFactory =
>> DocumentBuilderFactory.newInstance();
>>
>> documentBuilderFactory.setNamespaceAware(true);
>>
>> DocumentBuilder documentBuilder =
>> documentBuilderFactory.newDocumentBuilder();
>>
>> Document doc = documentBuilder.newDocument();
>>
>> Message msg = call.getResponseMessage();
>>
>> SOAPBody body = msg.getSOAPBody();
>>
>> NodeList nodes = body.getChildNodes();
>>
>> for (int i = 0; i < nodes.getLength(); i++) {
>>
>> Node node = doc.importNode(nodes.item(i), true);
>>
>> doc.appendChild(node);
>>
>> }
>>
> I thought a document was only allowed to have one child...
>> // the processor is the generated XMLProcessor subclass
>>
>> resource = processor.load(doc, null);
>>
>> Unfortunately I get the exception shown below (I can load the same XML
>> if
>> it is in a file that is opened by the generated editor). Can anyone shed
>> some light on this problem or suggest a better way of doing this.
>>
> It's hard to say without seeing what the XML looks like. You've tried
> serializing the DOM to see if it looks correct?
>> Thank you in advance.
>>
>> Uday
>>
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
>> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)
>>
>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:422)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:606)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResou rceImpl.java:577)
>>
>> at
>> org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcesso r.java:268)
>>
>> at
>> ws.kabe.strikeiron.ui.views.ZipCodeValidator.earlyStartup(Zi pCodeValidator.java:102)
>>
>> at
>> org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup (EarlyStartupRunnable.java:87)
>>
>> at
>> org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartu pRunnable.java:66)
>>
>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>
>> at org.eclipse.ui.internal.Workbench$20.run(Workbench.java:1759 )
>>
>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
>>
>> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1739)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1703)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1647)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot (XMLHandler.java:1229)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1157)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:528)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:517)
>>
>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:404)
>>
>> ... 9 more
>>
>>
>>



Re: How to use XMLResource.load(Node node, ...) to load an Ecore model [message #420456 is a reply to message #420452] Mon, 30 June 2008 20:35 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.
--------------070700090004010405020000
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Uday,

Comments below.

Uday Kabe wrote:
> Thanks Ed. Nice to "talk" to you again.
>
> Actually there is only one child element. You can view the serialized DOM
> document in the attached file.
>
Is that really how it serializes? I.e., you've serialized the DOM you
produced to see what it actually looks like, in particular to confirm
the namespace are correct...
> I am basically trying to marry Apache Axis (which is used by WTP tooling to
> generate the Web service client code) to EMF. Apache Axis handles the web
> service SOAP-based interaction. I then try to create an instance model from
> the response message.
>
I wonder if this option couldn't be used so that you can process the
element without importing it into a new document?

/**
* This is option should be used when loading a resource from a
DOM Element node, to specify
* that load method should take into account all the namespaces
declarations in scope for this node
* (by visiting parents of the node being loaded).
* Otherwise, user have to make sure that Element node being
loaded has namespace well-formed content.
* <p>
* Note that loading will only succeed if the subset of DOM being
loaded could be treated as a valid resource according
* to the model. </p>
*/
String OPTION_DOM_USE_NAMESPACES_IN_SCOPE =
"DOM_USE_NAMESPACES_IN_SCOPE";

> The attached file, My3.wslite, contains the response body. When I import
> the attached wsdl
> file( http://wslite.strikeiron.com/zipcodeinfolite01/ZIPCodeInfoLi te.asmx?WSDL),
> the importer creates wslite.ecore with NsPrefix set to "wslite" and NsURI
> set to http://www.wslite.strikeiron.com/wslite.ecore. I manually set the
> prefix to be empty and the nsuri to http://www.wslite.strikeiron.com.
An empty prefix is generally a good way to end up with problems because
once you use the empty prefix to denote the non-null namespace, every
nested element will be implicitly qualified which means you'd better not
be expecting to use any elements from the null namespace nor have any
qualified local element declarations (where local element declarations
are unqualified by default). I see in your WSDL you've made them be
qualified.
> I
> then generated the code. I also added a generated_package extension for
> http://www.wslite.strikeiron.com and an extension_parser extension for
> "wslite". By doing this, I am trying to match the namespace and prefix on
> the response. I have also overridden the makeDefaultHandler() method of the
> generates ResourceImpl as follows:
>
You might want to use the DocumentRoot's getXMLNSPrefix map for
controlling the prefix rather than default it in the model...
> /* (non-Javadoc)
>
> * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#createXMLLoad ()
>
> */
>
> protected XMLLoad createXMLLoad() {
>
> return new XMLLoadImpl(createXMLHelper()) {
>
> protected DefaultHandler makeDefaultHandler() {
>
> return new SAXXMLHandler(resource, helper, options) {
>
> protected EPackage handleMissingPackage(String uriString) {
>
So whenever a package isn't found, any and all packages, you'll just
home this one will do the trick? You're sure you should just be
registering this package in the resource set's package registry with
the alternative nsURIs you'd like it to be known by?
> return WslitePackage.eINSTANCE;
>
> }
>
> };
>
> }
>
> };
>
> }
>
> The genereated editor opens the attached file with the wslite extension
> without a problem. I just can't get the "same" thing to load(Node, ...)
> via the XMLProcessor subclass.
>
> Thanks.
>
> Uday
>
>
>
> "Ed Merks" <Ed.Merks@gmail.com> wrote in message
> news:g4b1qo$29s$1@build.eclipse.org...
>
>> Uday,
>>
>> Comments below.
>>
>> Uday Kabe wrote:
>>
>>> I have imported a WSDL file to create an EMF ecore/genmodel. Now I am
>>> trying to generate EMF EObjcets from the body of a SOAP response by using
>>> the load(Node node, ...) method of the generated XMLProcessor subclass.
>>> Here is how I structure the code (sorry for the horrible formatting):
>>>
>>> DocumentBuilderFactory documentBuilderFactory =
>>> DocumentBuilderFactory.newInstance();
>>>
>>> documentBuilderFactory.setNamespaceAware(true);
>>>
>>> DocumentBuilder documentBuilder =
>>> documentBuilderFactory.newDocumentBuilder();
>>>
>>> Document doc = documentBuilder.newDocument();
>>>
>>> Message msg = call.getResponseMessage();
>>>
>>> SOAPBody body = msg.getSOAPBody();
>>>
>>> NodeList nodes = body.getChildNodes();
>>>
>>> for (int i = 0; i < nodes.getLength(); i++) {
>>>
>>> Node node = doc.importNode(nodes.item(i), true);
>>>
>>> doc.appendChild(node);
>>>
>>> }
>>>
>>>
>> I thought a document was only allowed to have one child...
>>
>>> // the processor is the generated XMLProcessor subclass
>>>
>>> resource = processor.load(doc, null);
>>>
>>> Unfortunately I get the exception shown below (I can load the same XML
>>> if
>>> it is in a file that is opened by the generated editor). Can anyone shed
>>> some light on this problem or suggest a better way of doing this.
>>>
>>>
>> It's hard to say without seeing what the XML looks like. You've tried
>> serializing the DOM to see if it looks correct?
>>
>>> Thank you in advance.
>>>
>>> Uday
>>>
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
>>> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)
>>>
>>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:422)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:606)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResou rceImpl.java:577)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcesso r.java:268)
>>>
>>> at
>>> ws.kabe.strikeiron.ui.views.ZipCodeValidator.earlyStartup(Zi pCodeValidator.java:102)
>>>
>>> at
>>> org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup (EarlyStartupRunnable.java:87)
>>>
>>> at
>>> org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartu pRunnable.java:66)
>>>
>>> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
>>>
>>> at org.eclipse.ui.internal.Workbench$20.run(Workbench.java:1759 )
>>>
>>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
>>>
>>> Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>>> 'GetZIPCodeInfoResponse' not found. (xml, -1, -1)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1739)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1703)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1647)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot (XMLHandler.java:1229)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1157)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:528)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:517)
>>>
>>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:404)
>>>
>>> ... 9 more
>>>
>>>
>>>
>>>
>
>
>

--------------070700090004010405020000
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">
Uday,<br>
<br>
Comments below.<br>
<br>
Uday Kabe wrote:
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap="">Thanks Ed. Nice to "talk" to you again.

Actually there is only one child element. You can view the serialized DOM
document in the attached file.
</pre>
</blockquote>
Is that really how it serializes?&nbsp; I.e., you've serialized the DOM you
produced to see what it actually looks like, in particular to confirm
the namespace are correct...<br>
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap="">I am basically trying to marry Apache Axis (which is used by WTP tooling to
generate the Web service client code) to EMF. Apache Axis handles the web
service SOAP-based interaction. I then try to create an instance model from
the response message.
</pre>
</blockquote>
I wonder if this option couldn't be used so that you can process the
element without importing it into a new document?<small><br>
</small>
<blockquote><small>&nbsp; /**</small><br>
<small>&nbsp;&nbsp; * This is option should be used when loading a resource
from a DOM Element node, to specify</small><br>
<small>&nbsp;&nbsp; * that load method should take into account all the
namespaces declarations in scope for this node </small><br>
<small>&nbsp;&nbsp; * (by visiting parents of the node being loaded). </small><br>
<small>&nbsp;&nbsp; * Otherwise, user have to make sure that Element node being
loaded has namespace well-formed content.</small><br>
<small>&nbsp;&nbsp; * &lt;p&gt;</small><br>
<small>&nbsp;&nbsp; * Note that loading will only succeed if the subset of DOM
being loaded could be treated as a valid resource according</small><br>
<small>&nbsp;&nbsp; * to the model. &lt;/p&gt;</small><br>
<small>&nbsp;&nbsp; */</small><br>
<small>&nbsp; String OPTION_DOM_USE_NAMESPACES_IN_SCOPE =
"DOM_USE_NAMESPACES_IN_SCOPE";</small><br>
</blockquote>
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap="">The attached file, My3.wslite, contains the response body. When I import
the attached wsdl
file(<a class="moz-txt-link-freetext" href=" http://wslite.strikeiron.com/zipcodeinfolite01/ZIPCodeInfoLi te.asmx?WSDL"> http://wslite.strikeiron.com/zipcodeinfolite01/ZIPCodeInfoLi te.asmx?WSDL</a>),
the importer creates wslite.ecore with NsPrefix set to "wslite" and NsURI
set to <a class="moz-txt-link-freetext" href="http://www.wslite.strikeiron.com/wslite.ecore">http://www.wslite.strikeiron.com/wslite.ecore</a>. I manually set the
prefix to be empty and the nsuri to <a class="moz-txt-link-freetext" href="http://www.wslite.strikeiron.com">http://www.wslite.strikeiron.com</a>. </pre>
</blockquote>
An empty prefix is generally a good way to end up with problems because
once you use the empty prefix to denote the non-null namespace, every
nested element will be implicitly qualified which means you'd better
not be expecting to use any elements from the null namespace nor have
any qualified local element declarations (where local element
declarations are unqualified by default).&nbsp; I see in your WSDL you've
made them be qualified.<br>
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap=""> I
then generated the code. I also added a generated_package extension for
<a class="moz-txt-link-freetext" href="http://www.wslite.strikeiron.com">http://www.wslite.strikeiron.com</a> and an extension_parser extension for
"wslite". By doing this, I am trying to match the namespace and prefix on
the response. I have also overridden the makeDefaultHandler() method of the
generates ResourceImpl as follows:
</pre>
</blockquote>
You might want to use the DocumentRoot's getXMLNSPrefix map for
controlling the prefix rather than default it in the model...<br>
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap="">
/* (non-Javadoc)

* @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#createXMLLoad ()

*/

protected XMLLoad createXMLLoad() {

return new XMLLoadImpl(createXMLHelper()) {

protected DefaultHandler makeDefaultHandler() {

return new SAXXMLHandler(resource, helper, options) {

protected EPackage handleMissingPackage(String uriString) {
</pre>
</blockquote>
So whenever a package isn't found, any and all packages, you'll just
home this one will do the trick?&nbsp; You're sure you should just be
registering this package in the resource set's package registry&nbsp; with
the alternative nsURIs you'd like it to be known by?<br>
<blockquote cite="mid:g4b4fi$tni$1@build.eclipse.org" type="cite">
<pre wrap="">
return WslitePackage.eINSTANCE;

}

};

}

};

}

The genereated editor opens the attached file with the wslite extension
without a problem. I just can't get the "same" thing to load(Node, ...)
via the XMLProcessor subclass.

Thanks.

Uday



"Ed Merks" <a class="moz-txt-link-rfc2396E" href="mailto:Ed.Merks@gmail.com">&lt;Ed.Merks@gmail.com&gt;</a> wrote in message
<a class="moz-txt-link-freetext" href="news:g4b1qo$29s$1@build.eclipse.org">news:g4b1qo$29s$1@build.eclipse.org</a>...
</pre>
<blockquote type="cite">
<pre wrap="">Uday,

Comments below.

Uday Kabe wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I have imported a WSDL file to create an EMF ecore/genmodel. Now I am
trying to generate EMF EObjcets from the body of a SOAP response by using
the load(Node node, ...) method of the generated XMLProcessor subclass.
Here is how I structure the code (sorry for the horrible formatting):

DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();

documentBuilderFactory.setNamespaceAware(true);

DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();

Document doc = documentBuilder.newDocument();

Message msg = call.getResponseMessage();

SOAPBody body = msg.getSOAPBody();

NodeList nodes = body.getChildNodes();

for (int i = 0; i &lt; nodes.getLength(); i++) {

Node node = doc.importNode(nodes.item(i), true);

doc.appendChild(node);

}

</pre>
</blockquote>
<pre wrap="">I thought a document was only allowed to have one child...
</pre>
<blockquote type="cite">
<pre wrap=""> // the processor is the generated XMLProcessor subclass

resource = processor.load(doc, null);

Unfortunately I get the exception shown below (I can load the same XML
if
it is in a file that is opened by the generated editor). Can anyone shed
some light on this problem or suggest a better way of doing this.

</pre>
</blockquote>
<pre wrap="">It's hard to say without seeing what the XML looks like. You've tried
serializing the DOM to see if it looks correct?
</pre>
<blockquote type="cite">
<pre wrap="">Thank you in advance.

Uday

org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Feature
'GetZIPCodeInfoResponse' not found. (xml, -1, -1)

at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLL oadImpl.java:80)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:422)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:606)

at
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResou rceImpl.java:577)

at
org.eclipse.emf.ecore.xmi.util.XMLProcessor.load(XMLProcesso r.java:268)

at
ws.kabe.strikeiron.ui.views.ZipCodeValidator.earlyStartup(Zi pCodeValidator.java:102)

at
org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup (EarlyStartupRunnable.java:87)

at
org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartu pRunnable.java:66)

at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)

at org.eclipse.ui.internal.Workbench$20.run(Workbench.java:1759 )

at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)

Caused by: org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
'GetZIPCodeInfoResponse' not found. (xml, -1, -1)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1739)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1703)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLH andler.java:1647)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot (XMLHandler.java:1229)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1157)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1239)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:877)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:860)

at
org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:627)

at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:528)

at
org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.traverse(XMLLoadI mpl.java:517)

at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:404)

.... 9 more



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

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

--------------070700090004010405020000--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:ID and IDREF 1 to 1 link
Next Topic:Warnings in generated code for model package
Goto Forum:
  


Current Time: Thu Apr 25 06:08:10 GMT 2024

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

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

Back to the top