#!/bin/perl # # Rudolf demo: URI resolution - Handle2Rdf # daniel.brickley@bristol.ac.uk use CGI; require LWP::UserAgent; package HandleRDFDS; # A trivial subclass that doesn't follow redirects @HandleRDFDS::ISA = qw(LWP::UserAgent); sub redirect_ok() { return 0; } # magic of subclassing... ## Output our response as plain text for now (easier to demo) print "Content-type: text/plain\n\n"; # Issue: send text/x-rdf instead? my $data; my $cgi = new CGI; $cgi->import_names("WEB"); ## Get a Handle to de-reference my $handle = '/10.1045/january98-kirriemuir'; # Default test handle $handle = $WEB::URI || $handle; # get query string from web if running as CGI $handle =~ s/\s+//g; ## Strip whitespace from handle $handle =~ s/^hdl://; ## strip initial URI bit (if there is one) my $uri= 'hdl:'.$handle; ## the URI-shaped version for RDF use $handle =~ s/^\///g; ## Hardcoded knowledge of RDF Description Service for Handles ## (there are several of these; these could be described in RDF) my $URI= "http://hdl.handle.net/$handle"; ## Go get the (meta)data ## my $ua = new HandleRDFDS; my @locations = $ua->request(new HTTP::Request('HEAD', "$URI"))->header('Location'); ## If we got resolution information for this URI, reflect into RDF ## if (@locations) { print ''; print "\n\n\n"; foreach my $u (@locations) { print " \n";#eg; } print "\n"; print "\n\n"; } else { ## Otherwise... ? ## Duck the issue of handling unknown resource descriptions print ""; } print ' ';