Hi Ian,
Thanks for the example. I am doing something similar, except that I did
not want the program to exit when it detected the error, but simply
issue a warning - I have sorted that out now. Unfortunately in this case
I get this particular URI on-the-fly from another service - CKAN, along
with a bunch of other package information. So there is not much I can
do (want to do) in terms of probing it further.
Cheers,
Monika
On 25/08/11 00:38, Ian Dickinson wrote:
Hi Monika,
On 24/08/11 21:50, Monika Solanki wrote:
This is the URI
String uri="http://webenemasuno.linkeddata.es/metadata"
from where I am trying to read into a model using
Model m = FileManager.get().loadModel(uri);
I have tried several other ways of loading the model as well, nothing
seems to work. They all throw
ERROR [main] (RDFDefaultErrorHandler.java:44) -
http://webenemasuno.linkeddata.es/metadata(line 1 column 55): White
spaces are required between publicId and systemId.
and program stops execution, which is what I do not want. What am I
missing?
You need to catch the thrown exception. I've attached an example of
doing just that. I also set it to show some of the file that it's
trying to read, to help with debugging:
>>>>>
Failed to read from http://webenemasuno.linkeddata.es/metadata
because: org.xml.sax.SAXParseException; systemId:
http://webenemasuno.linkeddata.es/metadata; lineNumber: 1;
columnNumber: 55; White spaces are required between publicId and
systemId.
First 10 lines from http://webenemasuno.linkeddata.es/metadata
-----------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
<head>
<title>Index of /metadata</title>
</head>
<body>
<h1>Index of /metadata</h1>
<table><tr><th><img src="/icons/blank.gif" alt="[ICO]"></th><th><a
href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last
modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a
href="?C=D;O=A">Description</a></th></tr><tr><th
colspan="5"><hr></th></tr>
<tr><td valign="top"><img src="/icons/back.gif"
alt="[DIR]"></td><td><a href="/">Parent
Directory</a></td><td> </td><td align="right"> - </td></tr>
<tr><td valign="top"><img src="/icons/unknown.gif" alt="[
]"></td><td><a href="voidviajero.ttl">voidviajero.ttl</a></td><td
align="right">18-Jul-2011 21:48 </td><td align="right">2.0K</td></tr>
Exiting normally, model contains: 0 triples
<<<<<
So this program doesn't exit when it detects an error. It also shows
the problem in this particular case: the URI
http://webenemasuno.linkeddata.es/metadata resolves to a directory,
not a file, so you're seeing the default action from the web server
which is to list the files in that directory. You either need to refer
to the file you want to load explicitly, or set the .htaccess so that
there is a default file which will be served when you HTTP GET that URL.
Ian