NAME

RDF::Query - An RDF query implementation of SPARQL/RDQL in Perl for use with RDF::Redland and RDF::Core.

VERSION

This document describes RDF::Query version 1.044.

SYNOPSIS

my $query = new RDF::Query ( $rdql, undef, undef, 'rdql' );
my @rows = $query->execute( $model );

my $query = new RDF::Query ( $sparql, undef, undef, 'sparql' );
my $iterator = $query->execute( $model );
while (my $row = $iterator->()) {
  ...
}

DESCRIPTION

RDF::Query allows RDQL and SPARQL queries to be run against an RDF model, returning rows of matching results.

See http://www.w3.org/TR/rdf-sparql-query/ for more information on SPARQL. See http://www.w3.org/Submission/2004/SUBM-RDQL-20040109/ for more information on RDQL.

REQUIRES

RDF::Redland or RDF::Core

Parse::RecDescent (for RDF::Core)

LWP::Simple

DateTime::Format::W3CDTF

Scalar::Util

METHODS

new ( $query, $baseuri, $languri, $lang )

Returns a new RDF::Query object for the query specified. The query language used will be set if $languri or $lang is passed as the URI or name of the query language, otherwise the query defaults to SPARQL.

get ( $model )

Executes the query using the specified model, and returns the first row found.

execute ( $model, %args )

Executes the query using the specified model. If called in a list context, returns an array of rows, otherwise returns an iterator.

add_function ( $uri, $function )

Associates the custom function $function (a CODE reference) with the specified URI, allowing the function to be called by query FILTERs.

net_filter_function ( $uri )

Takes a URI specifying the location of a javascript implementation. Returns a code reference implementing the javascript function.

If the 'trusted_keys' option is set, a GPG signature at ${uri}.asc is retrieved and verified against the arrayref of trusted key fingerprints. A code reference is returned only if a trusted signature is found.

add_hook ( $uri, $function )

Associates the custom function $function (a CODE reference) with the RDF::Query code hook specified by $uri. Each function that has been associated with a particular hook will be called (in the order they were registered as hooks) when the hook event occurs. See "Defined Hooks" for more information.

parsed ()

Returns the parse tree.

error ()

Returns the last error the parser experienced.

Defined Hooks

http://kasei.us/code/rdf-query/hooks/post-create-model

Called after loading all external files to a temporary model in queries that use FROM and FROM NAMED.

Args: ( $query, $bridge )

$query is the RDF::Query object. $bridge is the model bridge (RDF::Query::Model::*) object.

Supported Built-in Operators and Functions

  • REGEX, BOUND, ISURI, ISBLANK, ISLITERAL

  • Data-typed literals: DATATYPE(string)

  • Language-typed literals: LANG(string), LANGMATCHES(string, lang)

  • Casting functions: xsd:dateTime, xsd:string

  • dateTime-equal, dateTime-greater-than

TODO

  • Built-in Operators and Functions

    http://www.w3.org/TR/rdf-sparql-query/#StandardOperations

    Casting functions: xsd:{boolean,double,float,decimal,integer}, rdf:{URIRef,Literal}, STR

    XPath functions: numeric-equal, numeric-less-than, numeric-greater-than, numeric-multiply, numeric-divide, numeric-add, numeric-subtract, not, matches

    SPARQL operators: sop:RDFterm-equal, sop:bound, sop:isURI, sop:isBlank, sop:isLiteral, sop:str, sop:lang, sop:datatype, sop:logical-or, sop:logical-and

AUTHOR

Gregory Todd Williams <greg@evilfunhouse.com>