NAME
RDF::RDFa::Generator - generate some data in RDFa
VERSION
0.01
DESCRIPTION
Constructor
"$gen = RDF::RDFa::Generator->new(style => $style, %options)"
Creates a new generator object. $style is one of the following
case-sensitive strings: 'HTML::Head' (the default), 'HTML::Hidden'
or 'HTML::Pretty'. You can also construct an object like this:
$gen = RDF::RDFa::Generator::HTML::Head->new(%options);
Options include:
* base - the base URL where the output data will be published.
This allows in some cases for the generated RDFa to include
relative URIs.
* data_context - if non-null, a URI (string) which indicates the
context (named graph) containing the data to generate RDFa for.
* ns - a {uri=>prefix} hashref of preferred CURIE prefixes. There
are already some defaults, and if you clash with them BAD THINGS
will happen.
* prefix_attr - use the @prefix attribute for CURIE prefixes (RDFa
1.1 only). Boolean, defaults to false.
* title - assign a
element for generated XHTML documents.
* version - set generated RDFa version. Valid values are '1.0'
(the default) or '1.1'.
Public Methods
"$gen->create_document($model)"
Creates a new RDFa file containing triples. $model is an
RDF::Trine::Model object providing the triples. Returns an
XML::LibXML::Document object suitable for serialising using its
"toString" method.
If you're planning on serving the RDFa with the text/html media
type, then it is recommended that you use HTML::HTML5::Writer to
serialise the document rather than "toString".
Can also be called as a class method:
$document = RDF::RDFa::Generator->create_document($model)
# Same as:
# $document = RDF::RDFa::Generator->new->create_document($model)
"$gen->inject_document($document, $model)"
Injects an existing document with triples. $document is an
XML::LibXML::Document to inject, or a well-formed XML string. $model
is an RDF::Trine::Model object providing the triples. Returns an
XML::LibXML::Document object suitable for serialising using its
"toString" method.
See "create_document" for information about serving the RDFa with
the text/html media type.
Can also be called as a class method. See "create_document" for
details.
"$gen->nodes($model)"
Provides triple-laden XML::LibXML::Elements to be added to a
document. $model is an RDF::Trine::Model object providing the
triples. If called in list context, returns a list of
XML::LibXML::Element objects which can be added to a document;
otherwise returns an XML::LibXML::NodeList containing a list of such
elements.
Can also be called as a class method. See "create_document" for
details.
Additionally the methods "serialize_model_to_file",
"serialize_model_to_string", "serialize_iterator_to_file" and
"serialize_iterator_to_string" are provided for compatibility with the
RDF::Trine::Serializer interface.
BUGS
Please report any bugs to .
SEE ALSO
HTML::HTML5::Writer, XML::LibXML, RDF::RDFa::Parser, RDF::Trine.
.
AUTHOR
Toby Inkster .
COPYRIGHT AND LICENCE
Copyright (C) 2010 by Toby Inkster
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself, either Perl version 5.8 or, at your
option, any later version of Perl 5 you may have available.
Icons
The icons in RDF::RDFa::Generator::HTML::Pretty are taken from the Tango
Project.