#!/usr/bin/perl -w
#
# SWAD-Europe: sample Perl client for Annotea SOAP RDF query demo
# Author: danbri@w3.org
# $Id: esw-anno.pl,v 1.2 2002/09/25 17:36:16 danbri Exp $
#
# This script composes a simple RDF query (in Squish), which is sent 
# using SOAP to a remote query service. The soap-encoded result set
# (a table, encoded as a list of field/value pairs) is decoded and printed.
#
# todo: 
#  - document strawman query language and protocol (proof of concept)
#  - links to soap writeup
#  - show other query forms for use with other style of annotation schemas
#  - demos: earl, image anno, normal annotea, dublin core, rss, ... ?
 
use SOAP::Lite;
my $uri = shift || 'http://www.w3.org/2001/sw/';
print "Looking up annotations on uri='$uri'";

my $query =    "SELECT ?x, ?c, ?b
                WHERE
                  (an::annotates ?x $uri)
                  (an::created ?x ?c)
                  (an::body ?x ?b)
                USING
                  an for http://www.w3.org/2000/10/annotation-ns#
                  dc for http://purl.org/dc/elements/1.1/";

my $soap = SOAP::Lite
 -> uri('http://rdfweb.org/RDF/RDFWeb/SOAPDemo')
 -> proxy('http://iggy.w3.org/danbri/CGI/soap'); # protocol and endpoint

my $r = $soap->squish($query)->result(); 

print "Result object $r: \n\n"; 		

foreach my $row ( @{$r} ) {
  my %h = %{$row } ;
  print "\n\n";
  foreach (keys %h) {
	print " $_ -> ", $h{$_}, " \n";
  }
};


##  More notes:
##  - my server code (a SOAP::Lite cgi wrapping Annotea) needs upgrading
##  - try it against other server implementations?
##  - pointers to TAP, AndyS's server and related work.
##  - use of RDFAuthor as GUI for query authoring?
##  - use of Parka DB as alternate backend?
