Sorry, I don't. Not having the relay.php stuff, I tried the following:
$(document).ready(function () {
var req = new XMLHttpRequest();
req.open("GET", "card.rdf", false);
req.send(null);
var data = req.responseXML;
var subjectdb = $.rdf().databank.load(data);
var outsubjectlist = "<ul>";
var targetQuery = $.rdf({ databank: subjectdb })
.prefix('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#')
.prefix('foaf','http://xmlns.com/foaf/0.1/')
.where('?target a foaf:Person')
.each(function () {
var tURI = this.target.value;
outsubjectlist += "<li>" + tURI + "</li>";
});
outsubjectlist += "</ul>";
console.log(outsubjectlist);
});
and the RDF/XML parsing seems to have worked fine and pulled out a
bunch of people. Certainly there was no out of memory error (in fact
it worked surprisingly quickly!).
So I wonder if there's some bad interaction with the AJAX request
somehow. Either that or my Mac has more memory. Perhaps you can put in
some logging to discover which part of the code is causing the out-of-
memory error (the loading of the RDF/XML or the querying of it)?
Note that in the above I changed the line:
tURI = this.target.uri;
to
tURI = this.target.value;
and the line:
.where('?target rdf:type foaf:Person')
to:
.where('?target a foaf:Person')
The latter is aesthetic, the former a bug in the original code (I
removed the .uri property in favour of .value a while ago).
Sorry I can't be more help,
Jeni
--
Jeni Tennison
http://www.jenitennison.com
Thanks a lot for your help; very much appreciated!
> req.open("GET", "card.rdf", false);
Hm. Anyway, still the parsing of a *remote* RDF/XML doesn't work. The
'relay.php' is essentially:
<?php
if (isset($_GET['URI'])) {
$URI = $_GET['URI'];
curl_get_file_contents($URI);
}
function curl_get_file_contents($URI) {
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_VERBOSE, 0);
curl_setopt($c, CURLOPT_HTTPGET, 1);
curl_setopt($c, CURLOPT_HEADER, 0);
curl_setopt($c, CURLOPT_URL, $URI);
curl_setopt($c, CURLOPT_TIMEOUT, 30);
echo curl_exec($c);
curl_close($c);
}
?>
But still, it takes ages to execute, then eats up all memory and I have to
force-quit FF.
> ... Either that or my Mac has more memory. ...
Are 4GB sufficient? ;)
> Perhaps you can put in
> some logging to discover which part of the code is causing the out-of-
> memory error (the loading of the RDF/XML or the querying of it)?
Unfortunately not. It dies before I even can react ...
Btw, the entire code is now available at [1] ... I still get weird
'uncaught exception: [object Object]' and I don't know where to look at (for
example using the lidaman bookmarklet from [2] on my FOAF homepage [3]).
> The latter is aesthetic, the former a bug in the original code (I
> removed the .uri property in favour of .value a while ago).
I guess we need to update the Wiki; it's still full of '.uri' ;)
> Sorry I can't be more help,
Your are! Always! :)
Cheers,
Michael
[1] http://bitbucket.org/mhausenblas/lidaman/
[2] http://ld2sd.deri.org/lidaman/
[3] http://sw-app.org/mic.xhtml
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/
[snip] Hmm, nope!
I just tried it locally at
http://localhost/proxy.php?URI=file:///etc/passwd and didn't like what I
saw... :)
Dan
> [snip] Hmm, nope!
What, nope? :)
> I just tried it locally at
> http://localhost/proxy.php?URI=file:///etc/passwd and didn't like what I
> saw... :)
Based on your recent experience I do understand what you mean, but can you
be a bit more specific, please? Can you propose an alternative solution? I'm
certainly no skilled developer, just doing proof of concept things so that
one can take over to implement it properly. But I'm eager to learn ...
Cheers,
Michael
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/
Basic idea is that the code you shipped will dereference *any* URI that
the PHP interpreter can access. This includes file: URIs on the box it
runs on, plus perhaps http://intranet/ or others that shouldn't be
proxied. So it should minimally disallow file: URIs, and come with a big
health warning plus example of configuring to exclude URIs that
shouldn't be accessed.
cheers,
Dan
Thanks, yeah, will do. Btw, anyone aware of a conneg module for JS?
Maybe worth an issue for rdfquery. Jenni, what do you think?
Cheers,
Michael
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/
> From: Dan Brickley <dan...@danbri.org>
> Date: Tue, 28 Apr 2009 09:02:05 +0200
> To: Michael Hausenblas <michael.h...@deri.org>
> Cc: <rdfq...@googlegroups.com>
> Subject: Re: [rdfQuery] Re: Parsing RDF/XML problems
>
I think you can set headers for this in the XML HTTP Request API,
http://www.w3.org/TR/XMLHttpRequest/#setrequestheader
You can do this from jquery, see
http://blog.jquery.com/2006/12/12/jquery-104/
cheers,
Dan
Cheers,
Michael
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/
> From: Dan Brickley <dan...@danbri.org>
> Date: Tue, 28 Apr 2009 10:36:36 +0200
> To: Michael Hausenblas <michael.h...@deri.org>
> Cc: <rdfq...@googlegroups.com>
> Subject: Re: [rdfQuery] Re: Parsing RDF/XML problems
>
> Hm. Anyway, still the parsing of a *remote* RDF/XML doesn't work.
OK, but I'm not sure how I can help without you doing a little more
debugging. Could you check that your AJAX call is actually returning
an XML document rather than a string or something? Could you try
storing that XML document in an intermediate variable and then parsing
it outside the AJAX call? Could you try a smaller test RDF/XML
document to see whether it's the size of the document (though I don't
think it is)? Could you try the RDF/XML document on your local server
rather than getting it through your proxy, to see if there's some
issue there?
Let me know what you find out.
Local seems to work fine. However, when I'm trying to parse a remote one
(via relay.php) it fails. My hunch is that I have to change relay.php to
serve the right media type and content. Will keep you posted ...
Thanks again for all your support!
Cheers,
Michael
--
Dr. Michael Hausenblas
DERI - Digital Enterprise Research Institute
National University of Ireland, Lower Dangan,
Galway, Ireland, Europe
Tel. +353 91 495730
http://sw-app.org/about.html
http://webofdata.wordpress.com/
> From: Jeni Tennison <je...@jenitennison.com>
> Date: Tue, 28 Apr 2009 21:18:39 +0100
> To: Michael Hausenblas <michael.h...@deri.org>
> Cc: <rdfq...@googlegroups.com>
> Subject: Re: [rdfQuery] Re: Parsing RDF/XML problems
>