NAME

RDF::RDFa::Template::SimpleQuery - Module to run a RAT Template Query very easily

DESCRIPTION

This module intends to be simple interface to do most of the tasks that most users of RDF::RDFa::Template would want to do.

SYNOPSIS

  my ($f)   = File::Util->new();
  my ($rat) = $f->load_file('dbpedia-comment/input.xhtml');
  my $query = RDF::RDFa::Template::SimpleQuery->new(rat => $rat,
						    filename => 'dbpedia-comment/input.ttl',
						    syntax => 'turtle');
  $query->execute;
  my $output = $query->rdfa_xhtml;
  $output->toStringC14N;

or

my ($f)   = File::Util->new();
my ($rat) = $f->load_file('dbpedia-comment/input.xhtml');
my ($rdf) = $f->load_file('dbpedia-comment/input.ttl');
my $rdfparser = RDF::Trine::Parser->new( 'turtle' );
my $storage = RDF::Trine::Store::Memory->temporary_store;
my $model = RDF::Trine::Model->new($storage);
$rdfparser->parse_into_model ( "http://example.org/", $rdf, $model );
my $query = RDF::RDFa::Template::SimpleQuery->new(rat => $rat, model => $model);
$query->execute;
my $output = $query->rdfa_xhtml;
$output->toStringC14N;

METHODS

new

The constructor. This takes a number of named arguments.

rat

The RDFa Template XHTML text to be parsed.

baseuri

The base URI to resolve any relative URIs. This is optional, "http://example.org/" is used if this is not given.

The following arguments are all used to give the module the data it shall query to fill the variables.

model

May be an RDF::Trine::Model object with the data to be queried. If given, it takes presedence over any other arguments.

filename

The full path of a file containing some RDF to be queried.

rdf

A string with some RDF to be queried.

syntax

A string giving the syntax to be parsed. Syntaxes supported by RDF::Trine::Parser are supported, e.g. turtle, rdfxml, etc. This parameter is required if filename or rdf is used.

execute

Now, really run it. This does the heavylifting, and therefore you should run this method manually in your application to control when it does happen. Returns the number of queries generated.

rdfa_xhtml

Once the query has been executed (see above), this method will return a XML::LibXML::Document containing the RDFa document with the variables inserted.

AUTHOR

Kjetil Kjernsmo, <kjetilk at cpan.org>

COPYRIGHT & LICENSE

Copyright 2010 Kjetil Kjernsmo.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.