Attean...r::RDFa(3pm)
π AtteanX::Serializer::RDFa β the RDFa Serializer for Attean π
okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's genuinely one of the cutest little serializer wrappers out there. no cap. let's get into it π¦
β¨ NAME β¨
AtteanX::Serializer::RDFa β RDFa Serializer for Attean
πΈ SYNOPSIS πΈ
here's the vibe, copy-paste ready, character for character:
use Attean;
use Attean::RDF qw(iri);
use URI::NamespaceMap;
my $ser = Attean->get_serializer('RDFa')->new;
my $string = $ser->serialize_iter_to_bytes($iter);
my $ns = URI::NamespaceMap->new( { ex => iri('http://example.org/') });
$ns->guess_and_add('foaf');
my $note = RDF::RDFa::Generator::HTML::Pretty::Note->new(iri('http://example.org/foo'), 'This is a Note');
my $ser = Attean->get_serializer('RDFa')->new(base => iri('http://example.org/'),
namespaces => $ns,
style => 'HTML::Pretty',
generator_options => { notes => [$note]});
$ser->serialize_iter_to_io($fh, $iter);
(yeah those indents in the original are doing their own thing, we respect the drip π )
π DESCRIPTION π
So this module lets you serialize RDFa in several different styles, which is lowkey the whole point. Under the hood it's built with Attean, wrapping around RDF::RDFa::Generator β that's the one doing all the heavy lifting, the actual main character energy. This module is just the cute lil interface.
It composes Attean::API::TripleSerializer and Attean::API::AbbreviatingSerializer. periodt.
π METHODS AND ATTRIBUTES π
Attributes
So, on top of the attributes that Attean::API::TripleSerializer requires β which, ngl, are not your problem, don't worry about them β you can also set these:
styleβ this one sets the serialization style thatRDF::RDFa::Generatoruses. go check its documentation for the details, bestie.namespacesβ a HASH reference mapping prefix strings toURI::NamespaceMapobjects.RDF::RDFa::Generatorwill help manage this map β again, its documentation has the tea.baseβ anAttean::API::IRIobject representing the base that relative IRIs in the serialized data get resolved against. There's some support for this inRDF::RDFa::Generator, but fr fr, currently it doesn't do much. πgenerator_optionsβ a HASH reference passed as options toRDF::RDFa::Generator'screate_documentmethod. this is usually the options that are specific to different styles β the synopsis above has an example if you wanna see it in the wild.
Methods
This module implements four required methods, and honestly? she ate:
serialize_iter_to_io( $fh, $iterator )β serializes the elements from theAttean::API::Iterator$iterator to theIO::Handleobject $fh.serialize_iter_to_bytes( $fh )β serializes the elements from theAttean::API::Iterator$iterator and returns the serialization as a UTF-8 encoded byte string.media_typesandfile_extensionsβ these two declare that HTML media types are used for the output of this module.
π BUGS π
Found a bug? Please report it here, bestie:
<https://github.com/kjetilk/p5-atteanx-serializer-rdfa/issues>
π SEE ALSO π
RDF::RDFa::Generator, RDF::Trine::Serializer::RDFa.
π§ TODO π§
the wishlist, the lil dreams, the "someday" list:
- The
styleattribute may be implemented with better constraints. - Make the writers (i.e. the code actually writing the DOM) configurable.
π AUTHOR π
Kjetil Kjernsmo <kjetilk@cpan.org>.
β COPYRIGHT AND LICENCE β
This software is copyright (c) 2017, 2018, 2019, 2021 by Kjetil Kjernsmo.
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.
(translation: no promises, she's just out here doing her best π)
and that's the whole page, bestie!! this one's from perl v5.36.0, dated 2022-11-19, filed under Attean...r::RDFa(3pm) π«Άπβ¨
π¦ where this page comes from
- debian bookworm: libatteanx-serializer-rdfa-perl 0.110-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libatteanx-serializer-rdfa-perl 0.110-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