Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Resource.getErrors()
Resource.getErrors() [message #417353] Thu, 06 March 2008 07:03 Go to next message
Waqas Ilyas is currently offline Waqas IlyasFriend
Messages: 80
Registered: July 2009
Member
Hi,

I needed to ask in what case is Resource.getErrors() useful. As I have seen
if any errors do occur during loading the XMLLoadImpl throws an exception
and does not return the resource. If I set
XMLResource.OPTION_RECORD_UNKNOWN_FEATURE to true in the default load
options before loading then no errors get reported. What I am hoping for is
that the file gets loaded but I still have a chance to see all the errors
that occurred. How do I do that?

The errors I am referring to are elements and attributes that may have been
specified in an XML that have no definition in the schema through which I
generaged my EMF model.
Re: Resource.getErrors() [message #417364 is a reply to message #417353] Thu, 06 March 2008 13:40 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------000503020607020602030006
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Waqas,

Comments below.

Waqas Ilyas wrote:
> Hi,
>
> I needed to ask in what case is Resource.getErrors() useful. As I have seen
> if any errors do occur during loading the XMLLoadImpl throws an exception
> and does not return the resource. If I set
> XMLResource.OPTION_RECORD_UNKNOWN_FEATURE to true in the default load
> options before loading then no errors get reported. What I am hoping for is
> that the file gets loaded but I still have a chance to see all the errors
> that occurred. How do I do that?
>
Just like the generated editor does:

| *try*
{
// Load the resource through the editing domain.
//
resource = editingDomain.getResourceSet().getResource(resourceURI, *true*);
}
*catch *(Exception e)
{
exception = e;
resource = editingDomain.getResourceSet().getResource(resourceURI, *false*);
}|

The point being, that the resource is created in the resource set and
loading it is a separate step that might throw an except. So even when
there is an exception, the resource will have been created and will be
present in the resource set. This is what ensures that a failed load
doesn't fail again every time a proxy is resolved...
> The errors I am referring to are elements and attributes that may have been
> specified in an XML that have no definition in the schema through which I
> generaged my EMF model.
>
>
>


--------------000503020607020602030006
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">
Waqas,<br>
<br>
Comments below.<br>
<br>
Waqas Ilyas wrote:
<blockquote cite="mid:fqo4vk$ocm$1@build.eclipse.org" type="cite">
<pre wrap="">Hi,

I needed to ask in what case is Resource.getErrors() useful. As I have seen
if any errors do occur during loading the XMLLoadImpl throws an exception
and does not return the resource. If I set
XMLResource.OPTION_RECORD_UNKNOWN_FEATURE to true in the default load
options before loading then no errors get reported. What I am hoping for is
that the file gets loaded but I still have a chance to see all the errors
that occurred. How do I do that?
</pre>
</blockquote>
Just like the generated editor does:<br>
<blockquote>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font
color="#7f0055"><b>try</b></font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">{</font><font
color="#000000"></font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#3f7f5f"> //&nbsp;Load&nbsp;the&nbsp;resource&nbsp;thr ough&nbsp;the&nbsp;editing&nbsp;domain. </font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#3f7f5f">//</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">resource&nbsp;=&nbsp;editingDomain.getResourceSet </font><font
color="#000000">()</font><font color="#000000">.getResource</font><font
color="#000000">(</font><font color="#000000">resourceURI,&nbsp;</font><font
color="#7f0055"><b>true</b></font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>catch&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">Exception&nbsp;e</font><font
color="#000000">)</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">exception&nbsp;=&nbsp;e;</font><br >
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">resource&nbsp;=&nbsp;editingDomain.getResourceSet </font><font
color="#000000">()</font><font color="#000000">.getResource</font><font
color="#000000">(</font><font color="#000000">resourceURI,&nbsp;</font><font
color="#7f0055"><b>false</b></font><font color="#000000">)</font><font
color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">}</font></code>
</td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --></blockquote>
The point being, that the resource is created in the resource set and
loading it is a separate step that might throw an except.&nbsp; So even when
there is an exception, the resource will have been created and will be
present in the resource set.&nbsp; This is what ensures that a failed load
doesn't fail again every time a proxy is resolved...<br>
<blockquote cite="mid:fqo4vk$ocm$1@build.eclipse.org" type="cite">
<pre wrap="">
The errors I am referring to are elements and attributes that may have been
specified in an XML that have no definition in the schema through which I
generaged my EMF model.


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

--------------000503020607020602030006--


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Customizing property values
Next Topic:item provider adapter 'getText' redefinitions
Goto Forum:
  


Current Time: Thu Apr 25 16:41:20 GMT 2024

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

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

Back to the top