1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#!/usr/bin/perl
use 5.010;
use strict;
use utf8;
use JSON;
use RDF::Trine;
use XML::Atom::Microformats;
my $xml = <<XML;
<feed xmlns="http://www.w3.org/2005/Atom">
<entry>
<id>http://example.com/id/1</id>
<content type="text/html">
<p class="vcard"><span class="fn">Alice</span></p>
</content>
<link rel="self" href="http://example.com/article/1" />
<link rel="profile" href="http://ufs.cc/x/hcard" />
</entry>
<entry xml:base="http://bob.com/">
<foo property=":fooble">lala</foo>
<id>http://example.com/id/2</id>
<content type="text/html">
<p class="vcard"><a href="/foo" class="fn url">Bob</a></p>
</content>
<link rel="self" href="http://example.com/article/2" />
</entry>
</feed>
XML
my $xamf = XML::Atom::Microformats->new_feed($xml, "http://example.net/");
#$xamf->assume_all_profiles;
print $xamf->json(pretty=>1,canonical=>1);
my $s = RDF::Trine::Serializer::NQuads->new;
print $s->serialize_model_to_string($xamf->model(atomowl=>1));
|