| 1 |
NAME |
| 2 |
AtteanX::Serializer::RDFa - RDFa Serializer for Attean |
| 3 |
|
| 4 |
SYNOPSIS |
| 5 |
use Attean; |
| 6 |
use Attean::RDF qw(iri); |
| 7 |
use URI::NamespaceMap; |
| 8 |
|
| 9 |
my $ser = Attean->get_serializer('RDFa')->new; |
| 10 |
my $string = $ser->serialize_iter_to_bytes($iter); |
| 11 |
|
| 12 |
my $ns = URI::NamespaceMap->new( { ex => iri('http://example.org/') }); |
| 13 |
$ns->guess_and_add('foaf'); |
| 14 |
my $note = RDF::RDFa::Generator::HTML::Pretty::Note->new(iri('http://example.org/foo'), 'This is a Note'); |
| 15 |
my $ser = Attean->get_serializer('RDFa')->new(base => iri('http://example.org/'), |
| 16 |
namespaces => $ns, |
| 17 |
style => 'HTML::Pretty', |
| 18 |
generator_options => { notes => [$note]}); |
| 19 |
$ser->serialize_iter_to_io($fh, $iter); |
| 20 |
|
| 21 |
DESCRIPTION |
| 22 |
This module can be used to serialize RDFa with several different styles. |
| 23 |
It is implemented using Attean to wrap around RDF::RDFa::Generator, which |
| 24 |
does the heavy lifting. It composes Attean::API::TripleSerializer and |
| 25 |
Attean::API::AbbreviatingSerializer. |
| 26 |
|
| 27 |
METHODS AND ATTRIBUTES |
| 28 |
Attributes |
| 29 |
In addition to attributes required by Attean::API::TripleSerializer that |
| 30 |
should not be a concern to users, the following attributes can be set: |
| 31 |
|
| 32 |
`style` |
| 33 |
This attribute sets the serialization style used by |
| 34 |
RDF::RDFa::Generator, see its documentation for details. |
| 35 |
|
| 36 |
`namespaces` |
| 37 |
A HASH reference mapping prefix strings to URI::NamespaceMap objects. |
| 38 |
RDF::RDFa::Generator will help manage this map, see its documentation |
| 39 |
for details. |
| 40 |
|
| 41 |
`base` |
| 42 |
An Attean::API::IRI object representing the base against which |
| 43 |
relative IRIs in the serialized data should be resolved. There is some |
| 44 |
support in RDF::RDFa::Generator, but currently, it doesn't do much. |
| 45 |
|
| 46 |
`generator_options` |
| 47 |
A HASH reference that will be passed as options to |
| 48 |
RDF::RDFa::Generator's `create_document` method. This is typically |
| 49 |
options that are specific to different styles, see synopsis for |
| 50 |
example. |
| 51 |
|
| 52 |
Methods |
| 53 |
This implements four required methods: |
| 54 |
|
| 55 |
`serialize_iter_to_io( $fh, $iterator )` |
| 56 |
Serializes the elements from the Attean::API::Iterator $iterator to |
| 57 |
the IO::Handle object $fh. |
| 58 |
|
| 59 |
`serialize_iter_to_bytes( $fh )` |
| 60 |
Serializes the elements from the Attean::API::Iterator $iterator and |
| 61 |
returns the serialization as a UTF-8 encoded byte string. |
| 62 |
|
| 63 |
`media_types` and `file_extensions` |
| 64 |
Declares that HTML media types are used for the output of this module. |
| 65 |
|
| 66 |
BUGS |
| 67 |
Please report any bugs to |
| 68 |
<https://github.com/kjetilk/p5-atteanx-serializer-rdfa/issues>. |
| 69 |
|
| 70 |
SEE ALSO |
| 71 |
RDF::RDFa::Generator, RDF::Trine::Serializer::RDFa. |
| 72 |
|
| 73 |
TODO |
| 74 |
* The `style` attribute may be implemented with better constraints. |
| 75 |
|
| 76 |
* Make the writers (i.e. the code actually writing the DOM) |
| 77 |
configurable. |
| 78 |
|
| 79 |
AUTHOR |
| 80 |
Kjetil Kjernsmo <[email protected]>. |
| 81 |
|
| 82 |
COPYRIGHT AND LICENCE |
| 83 |
This software is copyright (c) 2017, 2018, 2019, 2021 by Kjetil Kjernsmo. |
| 84 |
|
| 85 |
This is free software; you can redistribute it and/or modify it under the |
| 86 |
same terms as the Perl 5 programming language system itself. |
| 87 |
|
| 88 |
DISCLAIMER OF WARRANTIES |
| 89 |
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
| 90 |
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
| 91 |
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
| 92 |
|