NAME
RDF::RDFa::Parser - RDFa parser using XML::LibXML.
SYNOPSIS
use RDF::RDFa::Parser;
$parser = RDF::RDFa::Parser->new($xhtml, $baseuri);
$parser->consume;
$graph = $parser->graph;
VERSION
0.04
METHODS
- $p = RDF::RDFa::Parser->new($xhtml, $baseuri)
-
This method creates a new
RDF::RDFa::Parser
object and returns it. The XHTML document is parsed using XML::LibXML, which will throw an exception if it is not well-formed. RDF::RDFa::Parser does not catch the exception. The base URI is used to resolve relative URIs found in the document. - $p->consume
-
The document is parsed for RDFa. Nothing of interest is returned by this function, but the triples extracted from the document are passed to the callbacks as each one is found.
- $p->set_callbacks(\&func1, \&func2)
-
Set callbacks for handling RDF triples extracted from RDFa document. The first function is called when a triple is generated taking the form of (resource, resource, resource). The second function is called when a triple is generated taking the form of (resource, resource, literal).
The parameters passed to the first callback function are:
* A reference to the RDF::RDFa::Parser object * A reference to the XML::LibXML element being parsed * Subject URI or bnode * Predicate URI * Resource URI or bnode
The parameters passed to the second callback function are:
* A reference to the RDF::RDFa::Parser object * A reference to the XML::LibXML element being parsed * Subject URI or bnode * Predicate URI * Resource literal * Datatype URI (possibly undef or '') * Language (possibly undef or '')
In place of either or both functions you can use the string 'print' which sets the callback to a built-in function which prints the triples to STDOUT as Turtle. Either or both can be set to undef, in which case, no callback is called when a triple is found.
- $p->thing_described_by(1)
-
RDF::RDFa::Parser has a feature that allows it to use thing-described-by.org to create URIs for some blank nodes. It is disabled by default. This function can be used to turn it on (1) or off (0). May be called without a parameter which just returns the current status.
- $p->dom
-
Returns the parsed XML::LibXML::Document.
- $p->graph
-
Returns a graph of all RDF triples found in a Perl structure close to RDF/JSON. http://n2.talis.com/wiki/RDF_JSON_Specification
SEE ALSO
http://buzzword.org.uk/swignition/rdfa
COPYRIGHT
Copyright 2008, 2009 Toby Inkster
This file is dual licensed under:
The Artistic License
GNU General Public License 3.0
You may choose which of those two licences you are going to honour the
terms of, but you cannot pick and choose the parts which you like of
each. You must fulfil the licensing requirements of at least one of the
two licenses.
The Artistic License
<http://www.perl.com/language/misc/Artistic.html>
GNU General Public License 3.0
<http://www.gnu.org/licenses/gpl-3.0.html>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.