RDF::RDFa::Template::SimpleQuery - Module to run a RAT Template Query very easily
This module intends to be simple interface to do most of the tasks that most users of RDF::RDFa::Template would want to do.
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;
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;
The constructor. This takes a number of named arguments.
The RDFa Template XHTML text to be parsed.
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.
May be an RDF::Trine::Model object with the data to be queried. If given, it takes presedence over any other arguments.
The full path of a file containing some RDF to be queried.
A string with some RDF to be queried.
A string giving the syntax to be parsed. Syntaxes supported by RDF::Trine::Parser are supported, e.g.
rdfxml, etc. This parameter is required if
rdf is used.
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.
Once the query has been executed (see above), this method will return a XML::LibXML::Document containing the RDFa document with the variables inserted.
<kjetilk at cpan.org>
Copyright 2010 Kjetil Kjernsmo.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.