[xsl] Portability of data URIs

Subject: [xsl] Portability of data URIs
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: Fri, 13 Jun 2008 23:25:22 +0100
>>>>> "Michael" == Michael Kay <mike@xxxxxxxxxxxx> writes:

    Andrew> Settling on the complete function and which processors support
    Andrew> it would be good... although I guess using the data scheme is
    Andrew> just as processor dependent as an extension function.

    Michael> Arguably it's less portable, since there are no
    Michael> interrogatives to determine which URI schemes are
    Michael> supported...

In this case, there is a test. Fn:doc-available() is a reliable test for
the support of the data URI, in as much as it will return false() if
it is not supported, or if the URI is mal-formed, but will otherwise
return true(). Which is all that you need to know.

But as for what I said earlier today, about the only accurate thing was
that I was talking nonsense. Now I've had a couple of pints of mild
inside me, my thoughts are more lucid.
There is no problem with the encoding - you have to call
fn:encode-for-uri() to the content, and therefore declare the charset
as UTF-8.

So I think the best you can do for portability is to call
function-available on a data URI. If that returns true(), use that.
If not, call function-available() on known extension functions, one by
one.
Or try the extension functions first.

If all tests fail, then xsl:message.

As Andrew suggests, this could be written as a standard xsl:function.
It could then be placed it the FAQ.
-- 
Colin Adams
Preston Lancashire

Current Thread