|
|
| |
RDQL::Parser(3) |
User Contributed Perl Documentation |
RDQL::Parser(3) |
RDQL::Parser - A simple top-down LL(1) RDQL and SPARQL parser
use RDQL::Parser;
my $parser = RDQL::Parser->new();
my $query = <<QUERY;
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rss: <http://purl.org/rss/1.0/>
SELECT
?title ?link
FROM
<http://xmlhack.com/rss10.php>
WHERE
(?item, rdf:type <rss:item>)
(?item, rss:title, ?title)
(?item, rss:link ?link)
QUERY;
$parser->parse($query); #parse the query
# I.e.
$parser = bless( {
'distinct' => 0,
'constructPatterns' => [],
'prefixes' => {
'fn' => 'http://www.w3.org/2004/07/xpath-functions',
'op' => 'http://www.w3.org/2001/sw/DataAccess/operations',
'owl' => 'http://www.w3.org/2002/07/owl#',
'dcq' => 'http://purl.org/dc/terms/',
'dc' => 'http://purl.org/dc/elements/1.1/',
'foaf' => 'http://xmlns.com/foaf/0.1/',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'rss' => 'http://purl.org/rss/1.0/',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
'daml' => 'http://www.daml.org/2001/03/daml+oil#'
},
'graphPatterns' => [
{
'constraints' => [],
'optional' => 0,
'triplePatterns' => [
[
0,
'?item',
'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>',
'<rss:item>'
],
[
0,
'?item',
'<http://purl.org/rss/1.0/title>',
'?title'
],
[
0,
'?item',
'<http://purl.org/rss/1.0/link>',
'?link'
]
]
}
],
'sources' => [
'<http://xmlhack.com/rss10.php>'
],
'describes' => [],
'queryType' => 'SELECT',
'resultVars' => [
'?title',
'?link'
],
}, 'RDQL::Parser' );
$parser->serialize(*STDOUT, 'N-Triples'); #print on STDOUT the RDQL query as N-Triples if possible (or an error)
RDQL::Parser - A simple top-down LL(1) RDQL and SPARQL parser - see http://www.w3.org/TR/rdf-sparql-query/ and http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/
- $parser = new RDQL::Parser;
- parse( PARSER, QUERY )
-
If use Data::Dumper(3) to actually dumpo out the content of the PARSER variable after invoching the parse() method it lokks like:
$VAR1 = bless( {
'distinct' => 0,
'constructPatterns' => [],
'prefixes' => {
'fn' => 'http://www.w3.org/2004/07/xpath-functions',
'op' => 'http://www.w3.org/2001/sw/DataAccess/operations',
'owl' => 'http://www.w3.org/2002/07/owl#',
'dcq' => 'http://purl.org/dc/terms/',
'dc' => 'http://purl.org/dc/elements/1.1/',
'foaf' => 'http://xmlns.com/foaf/0.1/',
'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
'rss' => 'http://purl.org/rss/1.0/',
'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
'daml' => 'http://www.daml.org/2001/03/daml+oil#'
},
'graphPatterns' => [
{
'constraints' => [],
'optional' => 0,
'triplePatterns' => [
[
0,
'?item',
'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>',
'<rss:item>'
],
[
0,
'?item',
'<http://purl.org/rss/1.0/title>',
'?title'
],
[
0,
'?item',
'<http://purl.org/rss/1.0/link>',
'?link'
]
]
}
],
'sources' => [
'<http://xmlhack.com/rss10.php>'
],
'describes' => [],
'queryType' => 'SELECT',
'resultVars' => [
'?title',
'?link'
],
}, 'RDQL::Parser' );
The RDQL implementation is actually an extension of the original RDQL spec (http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/)
to allow more SQL-like Data Manipulation Language (DML) features like DELETE and INSERT - which is much more close to the original rdfdb
query language which SquishQL/RDQL are inspired to (see http://www.guha.com/rdfdb).
As well as the SPARQL one....?
DBD::RDFStore(3)
http://www.w3.org/TR/rdf-sparql-query/
http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/
http://ilrt.org/discovery/2002/04/query/
http://www.hpl.hp.com/semweb/doc/tutorial/RDQL/
http://rdfstore.sourceforge.net/documentation/papers/HPL-2002-110.pdf
- What's the difference between RDQL and SquishQL?
- None :-) The former is a bit of an extension of the original SquishQL
proposal defining a proper BNF to the query language; the only practical
difference is that triple patterns in the WHERE clause are expressed in a
different order s,p,o for RDQL while SquishQL uses '(p s o)' without commas.
In addition the URIs are expressed with angle brackets on RDQL while
SquishQL do not. For more about differences between the two languages see
http://rdfstore.sourceforge.net/documentation/papers/HPL-2002-110.pdf
- Is RDQL::Parser compliant to RDQL BNF?
- Yes
- Is RDQL::Parser compliant to SquishQL syntax ?
- Not yet :)
- What are RDQL::Parser extensions to RDQL BNF?
- RDQL::Parser leverage on RDFStore(3) to run proper free-text UTF-8
queries over literals; the two main extensions are
- * LIKE operator in AND clause
- * free-text triple matching like (?x, ?y, %"whatever"%)
Alberto Reggiori <areggiori@webweaving.org>
Andy Seaborne <andy_seaborne@hp.com> is the original author of RDQL
Libby Miller <libby.miller@bristol.ac.uk> is the original author of SquishQL
Hey! The above document had some coding errors, which are explained
below:
- Around line 1141:
- '=item' outside of any '=over'
- Around line 1143:
- You forgot a '=back' before '=head1'
- Around line 1145:
- '=item' outside of any '=over'
- Around line 1202:
- You forgot a '=back' before '=head1'
- Around line 1222:
- '=item' outside of any '=over'
- Around line 1238:
- Expected text after =item, not a bullet
- Around line 1240:
- Expected text after =item, not a bullet
- Around line 1242:
- You forgot a '=back' before '=head1'
Visit the GSP FreeBSD Man Page Interface. Output converted with ManDoc. |