File: 04parsing.t

package info (click to toggle)
libhtml-html5-microdata-parser-perl 0.100-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 400 kB
  • sloc: perl: 4,036; makefile: 7; sh: 1
file content (36 lines) | stat: -rw-r--r-- 1,072 bytes parent folder | download | duplicates (3)
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
use Test::More tests => 4;
use Test::RDF;

use HTML::HTML5::Microdata::Parser;
use RDF::Trine qw[iri literal variable statement blank];
use RDF::Trine::Namespace qw[rdf rdfs xsd owl];
my $s = RDF::Trine::Namespace->new('http://schema.org/');

my $p = HTML::HTML5::Microdata::Parser->new(<<'MARKUP', 'http://example.com/');
<div itemscope itemtype="http://schema.org/Person">
	<h1 itemprop="name">Alice</h1>
</div>
<div itemscope itemtype="http://schema.org/Person" lang="en-AU">
	<h1 itemprop="name">Bob</h1>
</div>
<div itemscope itemtype="http://schema.org/Person" itemid="#carol">
	<h1 itemprop="name">Carol</h1>
</div>
MARKUP

pattern_target($p->graph);

pattern_ok(
	statement(variable('x'), $rdf->type, $s->Person),
	statement(variable('x'), $s->name, literal('Alice')),
	);

pattern_ok(
	statement(variable('x'), $rdf->type, $s->Person),
	statement(variable('x'), $s->name, literal('Bob', 'en-AU')),
	);

pattern_ok(
	statement(iri('http://example.com/#carol'), $rdf->type, $s->Person),
	statement(iri('http://example.com/#carol'), $s->name, literal('Carol')),
	);