Re: posting xml to xsv

Donna Bergmark wrote:
> 
> Hello,
> I wish to use xsv to validate submissions to the Open Archive Initiative.
> Therefore, I would like to use your service from a cgi script.  I have
> attempted a POST to your url, with the content set to docFile=filename,
> style=text.  What I get back from the validator is:

Er... you're trying to pass docFile by reference? That won't work;
the process running on our machine can't read the file on your
machine; you have to send the _contents_, not the filename,
in the request.

> Traceback (most recent call last):
>   File "/usr/local/Jigsaw/Jigsaw/WWW/cgi-bin/new-xmlschema-check", line 250, in ?
>     serveRequest()
>   File "/usr/local/Jigsaw/Jigsaw/WWW/cgi-bin/new-xmlschema-check", line 155, in serveRequest
>     data = upFile.file.read()
> AttributeError: 'None' object has no attribute 'read'

What's going on here is (most probably) that the code expects
an uploaded file (see "11.2.2 Using the cgi module"
http://www.python.org/doc/current/lib/Using_the_cgi_module.html
for details)
but you're just giving it a string.

The diagnostic could be improved,
Henry, with a try..except block around the upFile.file.read() thingy
to catch this exceptional case.


Donna, try passing docFile by value, using multipart/form-data.
See multipart/form-data in the HTMl 4.01 spec
http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13.4.2

and/or your API documentation; if you're using python:

	12.4 MimeWriter -- Generic MIME file writer
	http://www.python.org/doc/current/lib/module-MimeWriter.html
	Mon, 16 Oct 2000 14:56:14 GMT

I'm sure there are examples of file upload clients out there, if you're
willing to surf around a bit.

> 
> It would appear that it is not picking up the docFile value.  To check
> it out, I decided to use the form itself, interactively.  It did nothing.
> The file in question is world-readable.
> 
> What could be wrong?  Donna

-- 
Dan Connolly, W3C http://www.w3.org/People/Connolly/

Received on Monday, 8 January 2001 15:08:28 UTC