Re: [xsl] Converting XML to an Escacped URL

Subject: Re: [xsl] Converting XML to an Escacped URL
From: Colin Paul Adams <colin@xxxxxxxxxxxxxxxxxx>
Date: 30 Oct 2005 18:50:57 +0000
>>>>> "Gary" == Gary Stewart <the.stewarg@xxxxxxxxx> writes:

    Gary> On 30 Oct 2005 18:13:24 +0000, Colin Paul Adams
    Gary> <colin@xxxxxxxxxxxxxxxxxx> wrote:

    Gary> Yeah; I am aware of that as a problem. I'm using it for
    Gary> testing really and the documents are quite short. I'll have
    Gary> to get POST working in the near future though :).

    >> Anyway, you have 3 functions in XPath 2.0 for escaping
    >> characters.  I take it you are using XML 1.1?

    Gary> XML 1.0 though I could start using 1.1. Is there a way of
    Gary> getting the nodeset as a string then?

The version of XML is irrelevant for this.
I was wondering if 1.0 element names need escaping at all.
But the text certainly will.

So I think you want a stylesheet that specifies xsl:output
method="text".

Then a template somthing like:

<xsl:template match="/">
data:text/html;charset=US-ASCII;base64,<xsl:apply-templates/>
</xsl:template

Then in subsequent templates write out the base64 encoding (you can
write an xsl:function for this) of each node.

Alternatively, you can omit the base64, and %encode everything with
escape-html-uri (if that's the right function for the data URI
scheme. (The RFC says:

"without ";base64", the data (as a sequence of
   octets) is represented using ASCII encoding for octets inside the
   range of safe URL characters and using the standard %xx hex encoding
   of URLs for octets outside that range."
)
-- 
Colin Adams
Preston Lancashire

Current Thread