use Test::More tests => 7; BEGIN { use_ok('RDF::RDFa::Parser') }; use RDF::RDFa::Parser; my $xhtml = < This is the title

Albert Einstein

Joe Bloggs
EOF $parser = RDF::RDFa::Parser->new($xhtml, 'http://example.com/einstein', { graph => 1, graph_attr => '{http://example.com/graphing}graph', graph_type => 'about', }); $parser->consume; ok($parser->graph('http://example.com/einstein#JOE')->count_statements( RDF::Trine::Node::Resource->new('http://example.com/einstein#maker'), RDF::Trine::Node::Resource->new('http://xmlns.com/foaf/0.1/name'), RDF::Trine::Node::Literal->new('Joe Bloggs', 'en') ), "The graph(uri) method returns the appropriate graph"); ok(!$parser->graph('_:RDFaDefaultGraph')->count_statements( RDF::Trine::Node::Resource->new('http://example.com/einstein#maker'), RDF::Trine::Node::Resource->new('http://xmlns.com/foaf/0.1/name'), RDF::Trine::Node::Literal->new('Joe Bloggs', 'en') ), "Statement in a non-default graph isn't duplicated in the default graph."); ok($parser->graphs->{'http://example.com/einstein#JOE'}->count_statements( RDF::Trine::Node::Resource->new('http://example.com/einstein#maker'), RDF::Trine::Node::Resource->new('http://xmlns.com/foaf/0.1/name'), RDF::Trine::Node::Literal->new('Joe Bloggs', 'en') ), "The graphs() method returns a hashref of graphs"); my $iter = $parser->graph->get_statements( RDF::Trine::Node::Resource->new('http://example.com/einstein#maker'), RDF::Trine::Node::Resource->new('http://xmlns.com/foaf/0.1/name'), RDF::Trine::Node::Literal->new('Joe Bloggs', 'en'), RDF::Trine::Node::Resource->new('http://example.com/einstein#JOE')); my $st = $iter->next; isa_ok($st, 'RDF::Trine::Statement::Quad'); isa_ok($st->context, 'RDF::Trine::Node::Resource'); ok($st->context->uri eq 'http://example.com/einstein#JOE', "Graph URI looks OK.");