AtteanX-Serializer-RDFa
view release on metacpan or search on metacpan
SYNOPSIS
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);
DESCRIPTION
This module can be used to serialize RDFa with several different styles.
It is implemented using Attean to wrap around RDF::RDFa::Generator, which
# SYNOPSIS
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);
# DESCRIPTION
This module can be used to serialize RDFa with several different
lib/AtteanX/Serializer/RDFa.pm view on Meta::CPAN
=head1 SYNOPSIS
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);
=head1 DESCRIPTION
plan skip_all => 'RDF::Prefixes is not installed' unless $rdfpr;
ok(my $ser = Attean->get_serializer('RDFa')->new, 'Assignment OK');
my $string = tests($ser);
like($string, qr|<meta name="generator" value="RDF::RDFa::Generator::HTML::Head"/>|, 'Head generator is correct');
like($string, qr|<link|, 'link element just local part');
like($string, qr|resource="http://example.org/Bar"|, 'Object present');
like($string, qr|property="ex:title" content="Dahut"|, 'Literals OK');
};
my $ns = URI::NamespaceMap->new( { ex => iri('http://example.org/') });
$ns->guess_and_add('foaf');
subtest 'Default generator with base and namespacemap' => sub {
$iter->reset;
ok(my $ser = Attean->get_serializer('RDFa')->new(base => iri('http://example.org/'),
namespaces => $ns)
, 'Assignment OK');
my $string = tests($ser);
like($string, qr|<meta name="generator" value="RDF::RDFa::Generator::HTML::Head"/>|, 'Head generator is correct');
like($string, qr|xmlns:foaf="http://xmlns.com/foaf/0.1/"|, 'FOAF is in there');
unlike($string, qr|xmlns:hydra="http://www.w3.org/ns/hydra/core#"|, 'But not hydra');
BEGIN {
use_ok('Attean') or BAIL_OUT "Attean required for tests";
use_ok('AtteanX::Serializer::RDFa');
use_ok('RDF::RDFa::Generator');
}
use Attean::RDF qw(iri);
use URI::NamespaceMap;
my $ns = URI::NamespaceMap->new( { ex => iri('http://example.org/') });
$ns->guess_and_add('foaf');
my $store = Attean->get_store('Memory')->new();
my $parser = Attean->get_parser('Turtle')->new(base=>'http://example.org/');
my $iter = $parser->parse_iter_from_bytes('<http://example.org/foo> a <http://example.org/Bar> ; <http://example.org/title> "Dahut"@fr ; <http://example.org/something> [ <http://example.org/else> "Foo" ; <http://example.org/pi> 3.14 ] .')->materializ...
ok(my $ser = Attean->get_serializer('RDFa')->new(base => iri('http://example.org/'),
namespaces => $ns)
, 'Assignment OK');
( run in 1.713 second using v1.01-cache-2.11-cpan-702932259ff )