[OAI-implementers] I have problems with OAI

Heinrich Stamerjohanns stamer at physnet.physik.uni-oldenburg.de
Fri Feb 25 06:58:46 EST 2005


On Wed, 23 Feb 2005, Daniel Manchego wrote:

Dear Daniel,

please try the attached patch (against 1.5), it will fix your problem.

Greetings, Heinrich

> 
> Hello,
> 
> I have implemented the OAI in my website, but at the time of making the
> test, it leaves the following error to me:
> 
> (30) Testing : GetRecord (invalid_id, oai_dc)
> URL :
> http://www.ifeanet.org/phpoai2-1.5/php_oai/oai2.php?verb=GetRecord&ident
> ifier=invalid\"id&metadataPrefix=oai_dc
> ------ Response from Xerces Schema Validation ------
> [Error] re.wWUN2I:7:81: cvc-datatype-valid.1.2.1: 'invalid"id' is not a
> valid value for 'anyURI'. [Error] re.wWUN2I:7:81: cvc-attribute.3: The
> value 'invalid"id' of attribute 'identifier' on element 'request' is not
> valid with respect to its type, 'identifierType'.
> /tmp/re.wWUN2I: 745;11;0 ms (4 elems, 7 attrs, 0 spaces, 149 chars)
> ------- End of Xerces Schema Validation Report  -------
> ------ Start of XML Response ------
> <?xml version="1.0" encoding="UTF-8"?>
> <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/"
>          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>          xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/
>          http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd">
>  <responseDate>2005-02-23T17:38:12Z</responseDate>
>  <request verb="GetRecord" identifier="invalid&quot;id"
> metadataPrefix="oai_dc">http://www.ifeanet.org/phpoai2-1.5/php_oai/oai2.
> php</request>
>  <error code="idDoesNotExist">The value &#039;invalidid&#039; of the
> identifier is illegal for this repository.</error> </OAI-PMH>
> 
> I have been reviewing, but I cannot find the error.
> 
> Could you help me, please?
> 
> Best Regards.
> 
> --
> Daniel Manchego 
> Web Administrator
> http://www.ifeanet.org
> INSTITUT FRANCAIS d'ETUDES ANDINES 
> Tlf. 4476070 Cel. 93569056
> Lima - Perú 
> 
> 
> _______________________________________________
> OAI-implementers mailing list
> List information, archives, preferences and to unsubscribe:
> http://www.openarchives.org/mailman/listinfo/oai-implementers
> 
> 

--
  Dr. Heinrich Stamerjohanns        Tel. +49-441-798-4276
  Institute for Science Networking  stamer at uni-oldenburg.de
  University of Oldenburg           http://isn.uni-oldenburg.de/~stamer
-------------- next part --------------
diff -u phpoai2-1.5/oai2/getrecord.php phpoai2-1.6/oai2/getrecord.php
--- phpoai2-1.5/oai2/getrecord.php	2004-07-02 16:35:21.000000000 +0200
+++ phpoai2-1.6/oai2/getrecord.php	2005-02-25 12:53:11.739801679 +0100
@@ -36,6 +36,9 @@
 	switch ($key) { 
 		case 'identifier':
 			$identifier = $val; 
+			if (!is_valid_uri($identifier)) {
+				$errors .= oai_error('badArgument', $key, $val);
+			}
 			break;
 
 		case  'metadataPrefix':
@@ -61,11 +64,11 @@
 } 
 
 // remove the OAI part to get the identifier
+if (!isset($errors)) {
 $id = str_replace($oaiprefix, '', $identifier); 
 if ($id == '') {
 	$errors .= oai_error('idDoesNotExist', '', $identifier); 
 }	
-if (!isset($errors)) {
 	$query = selectallQuery($id); 
 	$res = $db->query($query);
 
diff -u phpoai2-1.5/oai2/oaidp-util.php phpoai2-1.6/oai2/oaidp-util.php
--- phpoai2-1.5/oai2/oaidp-util.php	2004-07-02 17:14:44.000000000 +0200
+++ phpoai2-1.6/oai2/oaidp-util.php	2005-02-25 12:56:06.150812504 +0100
@@ -74,6 +74,9 @@
 
 		case 'idDoesNotExist' :
 			$text = "The value '$value' of the identifier is illegal for this repository.";
+			if (!is_valid_url($value)) {
+				$code = 'badArgument';
+			}
 			break;
 
 		case 'missingArgument' :
@@ -325,6 +328,10 @@
 	else return FALSE;
 }
 
+function is_valid_uri($url)
+{
+         return((bool) preg_match("'^[^:]+:(?:[a-z_0-9-]+[\.]{1})*(?:[a-z_0-9-]+\.)[a-z]{2,3}.*$'i", $url));
+} 
 
 function metadataHeader($prefix)
 {


More information about the OAI-implementers mailing list