#4 find_matching_tuples does not fully support RDQL syntax

open
nobody
None
5
2003-06-19
2003-06-19
Matthew Leingang
No

This is a bug I found in the find_matching_tuples
method of the RDQL_query class.

I tried the following query:

SELECT ?author
WHERE
(<http://www.mydomain.com/mydoc.html>,<dc:creator>,?author)
USING dc FOR <http://purl.org/dc/elements/1.1/>

(my iterator doesn't support multiple sources yet) and
got an empty result set. I traced the argments down
into find_matching_tuples and I found that here (lines
323--330ff of class_rdql.php):

// Check each element, if it is <something:foo>
then replace it by the
// namespace
if($elems[0]{0}=='<') {
preg_match("/\<([^>]*)\>/",$elems[0],$reqs);
$elems[0]=$reqs[1];
$predicate_parts=explode(':',$elems[0]);

$elems[0]=$ns[$predicate_parts[0]].$predicate_parts[1];
}

the URI <http://www.mydomain.com/mydoc.html> is
mistakenly determined to be a namespaced URI. Since
there is no namespace declared for http:, this URI gets
replaced by "//www.mydomain.com/mydoc.html".

There is a workaround: only use namespaced URIs in the
WHERE clause, or use the AND clause:

SELECT ?author
WHERE (<me:mydoc.html>,<dc:creator>,?author)
USING dc FOR <http://purl.org/dc/elements/1.1/>,
me for <http://www.mydomain.com/>

*or*

SELECT ?author
WHERE (?doc,<dc:creator>,?author)
AND ?doc=="http://www.mydomain.com/mydoc.html"
USING dc FOR <http://purl.org/dc/elements/1.1/>

However, the original syntax should be valid, as far as
I can tell from reading the RDQL grammar at
http://www.hpl.hp.com/semweb/rdql.htm (BTW, the link to
http://www.hpl.hp.com/semweb/rdql.html given in the
phpxmlclasses documentation is broken; perhaps this is
that document's correct location?). I don't think this
class would parse correctly any of the four examples
given on that page.

Discussion