[DAS2] Fwd: can't view XML from DAS2 server in IE4 or Safari
Andrew Dalke
dalke at dalkescientific.com
Wed Aug 16 01:29:40 UTC 2006
Steve:
> As for viewing das2xml data directly by clicking on das2 server links
> in
> Firefox, I have no problem. When you first click on a link returning
> das2xml
> formatted data (mime type=application/x-das-*+xml), Firefox should
> provide a
> dialog box asking what you want to do with it. Click "open with" and
> select
> Firefox itself.
I never would have thought of that.
A-ha. It works but it works by downloading the file, saving it to
a temp.xml file then doing the equivalent of "Firefox tmp.xml", which
opens a new window on a Mac. It doesn't open it in the current window
as I would like. And the temp file persists in my download directory.
I experimented with content negotiation, where the client may send an
accept header to the server with the desired content types. My server
supports "text/plain" (fasta), "text/xml", and
"application/x-das2segments+xml"
Examples below.
I did this because I want the documentation to say
"If the format parameter is not specified in the query string then the
server may use HTTP content negotiation to determine the most
appropriate representation. If multiple representations matc
then the das2xml version should be returned, if allowed.
and leave it at that. This includes the "if 'text/xml' exists in the
Accept field ..." solution we talked about earlier.
In the "An Annotationed Guide to the DAS spec" then include what
what that means and why it's done.
The Apache content negotiation strategy is at
http://httpd.apache.org/docs/1.3/content-negotiation.html
Using that scheme, the following describes possible variants for a DAS
service
URI: features
format: das2xml
Content-type: application/x-das2features+xml; qs=1.0
format: xml
Content-type: text/xml; qs=0.95
format: fasta
Content-type: text/plain; qs=0.95
where "qs" means "quality of service". Apache ranks solutions so "q*qs"
is largest.
Firefox sends
ACCEPT:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5
This orders the results as:
xml = 0.95*0.9 -> 0.855
fasta = 0.95*0.8 -> 0.76
das2xml = 1.0*0.5 -> 0.5
while Python's url fetcher does not send an Accept and curl sends "*/*".
Both of these would cause "das2xml" to be returned over other formats.
In other words, the "send 'text/xml' if the client asks for it else
send 'application/x-das2*+xml' " is an acceptable way to do conneg.
Here's what my test reference server does under different conditions.
## ask for text/plain, which returns FASTA
% curl -H "Accept: text/plain" -i http://localhost:8080/seq/fly_v1
HTTP/1.1 200 OK
Date: Wed, 16 Aug 2006 00:25:40 GMT
Server: CherryPy/2.2.1
Content-Length: 48
Content-Type: text/plain
Connection: close
>Chr1
ABCDEFG
>Chr2
abcdefgh
>Chr3
987654321
## ask for text/xml, which returns the normal XML as "text/xml"
% curl -H "Accept: text/xml" -i http://localhost:8080/seq/fly_v1
HTTP/1.1 200 OK
Date: Wed, 16 Aug 2006 00:26:02 GMT
Server: CherryPy/2.2.1
Content-Length: 435
Content-Type: text/xml
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<SEGMENTS xmlns="http://biodas.org/documents/das2">
<SEGMENT length="7" uri="fly_v1/1"
reference="http://example.com/das2/fly/v1/dna/Chr1" title="Chromosome
1" />
<SEGMENT length="8" uri="fly_v1/2"
reference="http://example.com/das2/fly/v1/dna/Chr2" title="Chromosome
2" />
<SEGMENT length="9" uri="fly_v1/3"
reference="http://example.com/das2/fly/v1/dna/Chr3" title="Chromosome
3" />
</SEGMENTS>
## ask for anything under the "application" namespace, with a
needless quality factor
% url -H "Accept: application/*;q=0.5" -i
http://localhost:8080/seq/fly_v1
HTTP/1.1 200 OK
Date: Wed, 16 Aug 2006 00:28:13 GMT
Server: CherryPy/2.2.1
Content-Length: 435
Content-Type: application/x-das2segments+xml
Connection: close
<?xml version="1.0" encoding="utf-8"?>
<SEGMENTS xmlns="http://biodas.org/documents/das2">
<SEGMENT length="7" uri="fly_v1/1"
reference="http://example.com/das2/fly/v1/dna/Chr1" title="Chromosome
1" />
<SEGMENT length="8" uri="fly_v1/2"
reference="http://example.com/das2/fly/v1/dna/Chr2" title="Chromosome
2" />
<SEGMENT length="9" uri="fly_v1/3"
reference="http://example.com/das2/fly/v1/dna/Chr3" title="Chromosome
3" />
</SEGMENTS>
## give an image if it's there, text/plain is next best, then an
application
% curl -H "Accept: image/*, application/*;q=0.5, text/plain;q=0.9" -i
http://localhost:8080/seq/fly_v1
HTTP/1.1 200 OK
Date: Wed, 16 Aug 2006 00:34:15 GMT
Server: CherryPy/2.2.1
Content-Length: 48
Content-Type: text/plain
Connection: close
>Chr1
ABCDEFG
>Chr2
abcdefgh
>Chr3
987654321
In my case the server has multiple text/plain outputs but FASTA always
wins over raw. I can force any format with the "format=" option,
which
ignores the "Accept" header completely.
% curl -H "Accept: text/xml" -i
'http://localhost:8080/seq/fly_v1/1?format=raw'
HTTP/1.1 200 OK
Date: Wed, 16 Aug 2006 00:35:54 GMT
Server: CherryPy/2.2.1
Content-Length: 7
Content-Type: text/plain
Connection: close
ABCDEFG
Andrew
dalke at dalkescientific.com
More information about the DAS2
mailing list