Toby Inkster > RDF-RDFa-Parser > RDF::RDFa::Parser::Config

Download:
RDF-RDFa-Parser-1.097.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  0
View/Report Bugs
Module Version: 1.097   Source  

NAME ^

RDF::RDFa::Parser::Config - configuration sets for RDFa parser

DESCRIPTION ^

The third argument to the constructor for RDF::RDFa::Parser objects is a configuration set. This module provides such configuration sets.

Confguration sets are needed by the parser so that it knows how to handle certain features which vary between different host languages, or different RDFa versions.

All you need to know about is the constructor:

  $config = RDF::RDFa::Parser::Config->new($host, $version, %options);

$host is the host language. Generally you would supply one of the following constants; the default is HOST_XHTML. Internet media types are accepted (e.g. 'text/html' or 'image/svg+xml'), but it's usually better to use a constant as some media types are shared (e.g. HTML4 and HTML5 both use the same media type).

$version is the RDFa version. Generally you would supply one of the following constants; the default is RDFA_LATEST.

Version guessing: the root element is inspected for an attribute 'version'. If this exists and matches /\bRDFa\s+(\d+\.\d+)\b/i then that is used as the version. Otherwise, the latest version is assumed.

%options is a hash of additional options to use which override the defaults. While many of these are useful, they probably also reduce conformance to the official RDFa specifications. The following options exist; defaults for XHTML+RDFa1.0 and XHTML+RDFa1.1 are shown in brackets.

An alternative constructor tagsoup is provided with a useful set of options for dealing with content "from the wild".

EXAMPLES ^

The following full example parses RDFa 1.1 in an Atom document, also using the non-default 'atom_parser' option which parses native Atom elements into the graph too.

  use RDF::RDFa::Parser;
  
  $config = RDF::RDFa::Parser::Config->new(
    RDF::RDFa::Parser::Config->HOST_ATOM,
    RDF::RDFa::Parser::Config->RDFA_11,
    atom_parser => 1,
    );
  $parser = RDF::RDFa::Parser->new_from_url($url, $config);
  $data   = $parser->graph;

The following configuration set parses XHTML+RDFa 1.1 while also parsing any RDF/XML chunks that are embedded in the document.

  use RDF::RDFa::Parser::Config qw(HOST_XHTML RDFA_11);
  $config = RDF::RDFa::Parser::Config->new(
    HOST_XHTML, RDFA_11, embedded_rdfxml=>1);
  $parser = RDF::RDFa::Parser->new_from_url($url, $config);
  $data   = $parser->graph;

The following config is good for dealing with (X)HTML content from the wild:

  $config = RDF::RDFa::Parser::Config->tagsoup;
  $parser = RDF::RDFa::Parser->new_from_url($url, $config);
  $data   = $parser->graph;

SEE ALSO ^

RDF::RDFa::Parser.

AUTHOR ^

Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE ^

Copyright 2008-2012 Toby Inkster

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

DISCLAIMER OF WARRANTIES ^

THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: