RDF::R...erator(3pm)
β¨ NAME β¨
RDF::RDFa::Generator β bestie, this module generates data for RDFa serialization. It's giving "I make RDFa out of thin air" energy and honestly? Iconic. π
πΈ DESCRIPTION πΈ
π Constructor
$gen = RDF::RDFa::Generator->new(style => $style, %options)
Okay so this creates a brand-new generator object for you, no cap. π«Ά The $style you pass in has to be one of these three strings, and heads up β it's case-sensitive, so don't get cute with the capitalization:
'HTML::Head'β the default, she's the main character π'HTML::Hidden''HTML::Pretty'
You can also construct an object like this, if that's more your vibe:
$gen = RDF::RDFa::Generator::HTML::Head->new(%options);
Now, the options, and yes we're listing every single one because we don't skip. π
baseβ the base URL where the output data is gonna be published. This lets the generated RDFa include relative URIs in some cases. Lowkey handy.data_contextβ if it's non-null, this is an Attean Blank or IRI object, or an RDF::Trine::Node, and it indicates the context (that's the named graph, bestie) containing the data you want RDFa for.namespacemapβ a URI::NamespaceMap object stuffed with your preferred CURIE prefixes. This is the preferred method, so peek at the note below. πnamespacesβ a{prefix=>uri}hashref of preferred CURIE prefixes.nsβ a{uri=>prefix}hashref of preferred CURIE prefixes. DEPRECATED β usenamespacesinstead, fr fr.prefix_attrβ use the@prefixattribute for CURIE prefixes (RDFa 1.1 only). Boolean, defaults to false.safe_xml_literalsβ stops XML literals from injecting arbitrary XHTML into the output. Boolean, defaults toFALSE. Safety first, babes. π‘οΈtitleβ assign a<title>element for generated XHTML documents.versionβ set the generated RDFa version. Valid values are'1.0'(the default) or'1.1'.
π¦ Public Methods π¦
π« $gen->create_document($model, %opts)
Creates a new RDFa file containing triples. $model is an Attean::QuadModel object (where the graph name is not used, okay?) providing the triples. Returns an XML::LibXML::Document object, suitable for serializing using its toString method. Slay.
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 serialize the document rather than toString. Trust. π
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)
Options can also be passed as a HASH. This is typically used for style-specific options.
π« $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 Attean::QuadModel object (where the graph name is not used) providing the triples. Returns an XML::LibXML::Document object, suitable for serializing 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 Attean::QuadModel object (where the graph name is not used) 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.
The HTML::Pretty generator can be passed a couple of additional options:
$gen->nodes($model, notes_heading=>'Additional Info', notes=>\@notes);
The notes are a list of RDF::RDFa::Generator::HTML::Pretty::Note objects which are added as notes to the end of each subject's data. Cute, right? π
π UPGRADING TO 0.200 π
The recommended upgrade path is to migrate your application to use Attean rather than RDF::Trine as your RDF library. If that is not an option, you may continue to use RDF::Trine, by using a compatibility layer. If you are using this module directly, to upgrade from earlier releases, you would simply add
use RDF::TrineX::Compatibility::Attean;
alongside the import of this module. It is in a separate distribution that needs to be installed. If you use the RDF::Trine::Serializer methods, you should instead use RDF::Trine::Serializer::RDFa.
π§ NOTE π§
Version 0.200 introduced a large number of changes to be compatible with both Attean and RDF::Trine. Some of these were backwards-incompatible, some were to support new features, such as the use of URI::NamespaceMap. Buckle up, bestie. π
π Backwards-incompatible changes
The methods serialize_model_to_file, serialize_model_to_string, serialize_iterator_to_file and serialize_iterator_to_string that were provided for compatibility with the RDF::Trine::Serializer interface have been moved to a module RDF::Trine::Serializer::RDFa that has to be installed separately to use this with RDF::Trine.
data_context previously accepted a plain-text string URI. Now, it requires an appropriate object, as documented. No more shortcuts, sorry. π
Since RDF 1.1 abandons untyped literals, this module also ceases to emit them. Periodt.
π Namespace mappings
The way namespace mappings are handled have been rewritten. Now, the preferred method to add them is to pass an URI::NamespaceMap object to namespacemap. This will override any other options.
The namespace mappings for the following prefixes will always be added: rdfa, rdf, rdfs and xsd.
If URI::NamespaceMap is not used, but namespaces is given as a hashref of prefix-URI pairs, the pairs will be added. If neither are given, all mappings from RDF::NS::Curated, which includes all if RDFa Initial Context will be added. Finally, any pairs from the deprecated ns option will be added, but a warning will be emitted. β οΈ
π BUGS π
Please report any bugs to <https://github.com/kjetilk/p5-rdf-rdfa-generator/issues>. Do it. Be the main character. π
π SEE ALSO π
You may want to use the framework-specific frontends: RDF::Trine::Serializer::RDFa or AtteanX::Serializer::RDFa.
Other relevant modules:
HTML::HTML5::Writer, XML::LibXML, RDF::RDFa::Parser, RDF::Trine, URI::NamespaceMap, Attean.
π AUTHOR π
Toby Inkster <tobyink@cpan.org>.
Kjetil Kjernsmo <kjetilk@cpan.org>.
β COPYRIGHT AND LICENCE β
Copyright (C) 2010 by Toby Inkster, 2017, 2018 Kjetil Kjernsmo
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 πΈ
RDF::RDFa::Generator::HTML::Pretty uses the FamFamFam Silk icons; see <http://famfamfam.com/lab/icons/silk/>.
That's the whole page, bestie β this is RDF::R...erator(3pm) from the User Contributed Perl Documentation, and it's yours truly from perl v5.40.0, dated 2025-01-21. Go forth and generate RDFa, you absolute legend. πβ¨π
π¦ where this page comes from
- debian trixie: librdf-rdfa-generator-perl 0.204-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-rdfa-generator-perl 0.204-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-rdfa-generator-perl 0.204-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms