[DAS2] XML-RPC based DAS2 validator
Andrew Dalke
dalke at dalkescientific.com
Tue Oct 24 10:03:54 EDT 2006
I've added an XML-RPC service to the DAS validator. Andreas will be
able
to use it to verify new DAS2 entries in his registry.
The entry point to the XML-RPC server is
http://cgi.biodas.org:8080/RPC2/
The trailing "/" is important - use ".../RPC" and the server will do
an HTTP redirect to ".../RPC/", which not all XML-RPC clients
understand.
At present the server implement a single RPC method named
"validate_url".
It takes two positional fields. The first is the required URL to
validate.
The second is the optional document type to validate against. If not
given
then the server will attempt to guess.
The response is a list of 2-element tuples. In each pair the first is
the severity level and will be one of
"info"
"warning"
"error"
"fatal"
"fatal" means the validator normally should not continue. I can
override
that, which I do in the XML-RPC service in order to generate more
messages.
"error" means the result does not meet the spec but the validator will
continue checking, at least in the normal case. (That too is
user-defined.)
"warning" is for things which are suspicious but not wrong, like using
"application/xml" instead of the DAS2 content-type, or having a uri
field
with an empty content. (This is legal; it refers to the document
itself.
It's just strange and likely indicates an error in the server.)
The "info" is for niggling details, like that the server guess the
document
type (in the case of application/xml response) by looking at the tag for
the top-level element.
Here's an example in Python's interactive shell. I'll first make a
proxy
to the remote server
>>> import xmlrpclib
>>> server = xmlrpclib.Server("http://cgi.biodas.org:8080/RPC2/")
then call the new method with a single parameter; the URL to validate.
>>> server.validate_url("http://das.biopackages.net/das/genome/human/")
[['info', "Assuming doctype of 'sources' based on Content-Type"]]
That's a list with a single element containing the (severity, message)
tuple.
The info statement came because it guessed the document type based on
the
content-type from the server. I can specify the document type directly
and skip that warning statement
>>> server.validate_url("http://das.biopackages.net/das/genome/human/",
"sources")
[]
Here's an example of validating a server with the wrong document type,
to show
what the error message look like. I've added newlines so the results
aren't
all on one string
>>>
server.validate_url("http://www.dasregistry.org/registry/das1/sources",
"types")
[['fatal', "Received Content-Type 'application/x-das-sources+xml',
expected 'application/x-das-types+xml'."],
['fatal', "Expected element '{http://biodas.org/documents/das2}TYPES'
but got '{http://biodas.org/documents/das2}SOURCES' at byte 41, line 2,
column 2"],
['error', 'element "SOURCES" from namespace
"http://biodas.org/documents/das2" not allowed in this context at byte
41, line 2, column 2']]
>>>
Andrew
dalke at dalkescientific.com
More information about the DAS2
mailing list