#!/usr/bin/perl -Tw # # parser-tests.pl - Redland OLD RDF Parser Tests Web Interface # # Copyright (C) 2001-2004, David Beckett http://www.dajobe.org/ # Copyright (C) 2001-2004, University of Bristol, UK http://www.bristol.ac.uk/ # # This package is Free Software and part of Redland http://librdf.org/ # # It is licensed under the following three licenses as alternatives: # 1. GNU Lesser General Public License (LGPL) V2.1 or any newer version # 2. GNU General Public License (GPL) V2 or any newer version # 3. Apache License, V2.0 or any newer version # # You may not use this file except in compliance with at least one of # the above three licenses. # # See LICENSE.html or LICENSE.txt at the top of this package for the # complete terms and further detail along with the license texts for # the licenses in COPYING.LIB, COPYING and LICENSE-2.0.txt respectively. # # # # CHANGE THIS FOR YOUR CONFIGURATION $::ROOT_DIR='/somewhere'; use strict; # Helps with broken web requests (missing headers) $ENV{'Content-Length'}||=0; # Tainting, dontcha know $ENV{'PATH'}="/bin:/usr/bin:/usr/local/bin"; # PT # Standard perl modules use CGI; use LWP::Simple; use URI::URL; use HTML::Entities; use Sys::Hostname; # Configuration my $RDF_NAMESPACE="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; my $RDFS_NAMESPACE="http://www.w3.org/2000/01/rdf-schema#"; my $DC_NAMESPACE="http://purl.org/dc/elements/1.1/"; my $PT_NAMESPACE="http://www.ilrt.bristol.ac.uk/discovery/2001/03/parser-tests/schema#"; my $RDF_TESTS_ROOT_URI='http://www.w3.org/2000/10/rdf-tests/'; my $PT_TEST_URI_STRING=$PT_NAMESPACE."test"; my $PT_TESTRESULT_URI_STRING=$PT_NAMESPACE."testResult"; my $PT_PARSER_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_NAMESPACE."parser"); my $PT_TEST_RESOURCE= RDF::Redland::Node->new_from_uri_string($PT_TEST_URI_STRING); my $PT_TESTRESULT_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_TESTRESULT_URI_STRING); my $PT_STATEMENTS_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_NAMESPACE."statements"); my $PT_OUTPUT_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_NAMESPACE."output"); my $PT_ERROR_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_NAMESPACE."error"); my $PT_EXPECTEDRESULT_PREDICATE= RDF::Redland::Node->new_from_uri_string($PT_NAMESPACE."expectedResult"); my $RDF_TYPE_PREDICATE= RDF::Redland::Node->new_from_uri_string($RDF_NAMESPACE."type"); my $RDFS_LABEL_PREDICATE= RDF::Redland::Node->new_from_uri_string($RDFS_NAMESPACE."label"); my $DC_DESCRIPTION_PREDICATE=RDF::Redland::Node->new_from_uri_string($DC_NAMESPACE."description"); my $DC_TITLE_PREDICATE=RDF::Redland::Node->new_from_uri_string($DC_NAMESPACE."title"); my $GOOD_COLOUR='#00ff00'; # green; my $WARN_COLOUR='#ffff00'; # yellow; my $BAD_COLOUR='#ff0000'; # red my(@commands)=qw(compare-all list-tests show-test-detail list-parsers show-parser-detail ); # removed: compare my(%command_labels)=('compare' =>'Compare two parsers (NOT IMPL)', 'compare-all' =>'Compare all parsers', 'list-tests' =>'List all known tests', 'show-test-detail' =>'Show test detail', 'list-parsers' =>'List all known parsers', 'show-parser-detail' =>'Show parser detail', 'upload' =>'Upload RDF/XML model'); my $working_parser='raptor'; my $default_command='compare-all'; my $tmp_dir="$::ROOT_DIR/tmp"; my $db_dir="$::ROOT_DIR/db"; my $db='pt'; my $log_file="$::ROOT_DIR/logs/parser-tests.log"; # Redland perl modules use RDF::Redland; ###################################################################### # Subroutines sub log_action ($$;$) { my($host, $message, $now)=@_; $host ||= '-'; $now ||= time; return unless open (LOG, ">>$log_file"); my($sec,$min,$hour,$mday,$mon,$year)=gmtime $now; my $date=sprintf("%04d-%02d-%02dT%02d:%02d:%02dZ",1900+$year,$mon+1,$mday,$hour,$min,$sec); print LOG "$host $date $message\n"; close(LOG); } sub end_page($) { my $q=shift; print <<'EOT';
The source code of this demonstration is available in the Redland distribution as demos/parser-tests.pl or from the Redland website
EOT print qq{