Attean...r::RDFa(3pm)

πŸ“¦
version 0.110 Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’– 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 that RDF::RDFa::Generator uses. go check its documentation for the details, bestie.
  • namespaces β€” a HASH reference mapping prefix strings to URI::NamespaceMap objects. RDF::RDFa::Generator will help manage this map β€” again, its documentation has the tea.
  • base β€” an Attean::API::IRI object representing the base that relative IRIs in the serialized data get resolved against. There's some support for this in RDF::RDFa::Generator, but fr fr, currently it doesn't do much. πŸ™ˆ
  • generator_options β€” a HASH reference passed as options to RDF::RDFa::Generator's create_document method. 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 the Attean::API::Iterator $iterator to the IO::Handle object $fh.
  • serialize_iter_to_bytes( $fh ) β€” serializes the elements from the Attean::API::Iterator $iterator and returns the serialization as a UTF-8 encoded byte string.
  • media_types and file_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 style attribute may be implemented with better constraints.
  • Make the writers (i.e. the code actually writing the DOM) configurable.

πŸ’œ AUTHOR πŸ’œ

Kjetil Kjernsmo <kjetilk@cpan.org>.


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