Created
June 7, 2011 12:25
-
-
Save danbri/1012134 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use RDF::Trine; | |
use RDF::Query; | |
use HTML::HTML5::Microdata::Parser; | |
my $html; | |
my $baseURI='http://schema.org/'; | |
open(IN, "full_md.html") || die "no file"; # beware, the html is escaped; save the markup first. | |
while(<IN>) { $html .= $_ ; } | |
my $parser = HTML::HTML5::Microdata::Parser->new($html, $baseURI); | |
my $model = $parser->graph; # RDF::Trine::Model | |
my $sparql = <<EOQ; | |
PREFIX so: <http://schema.org/> | |
PREFIX soo: <http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fschema.org%2FType%23%3A> | |
PREFIX sop: <http://www.w3.org/1999/xhtml/microdata#http%3A%2F%2Fschema.org%2FProperty%23%3A> | |
SELECT ?prop where { | |
?prop sop:range so:Person . | |
} | |
EOQ | |
my $query = RDF::Query->new( $sparql ); | |
my $iterator = $query->execute( $model ); | |
while (my $row = $iterator->next) { | |
print $row->{ 'prop' }->as_string; | |
print "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment