Re: [xsl] Javascript for extension functions

Subject: Re: [xsl] Javascript for extension functions
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 10 Sep 2007 07:48:39 +0200
Colin Paul Adams wrote:
    Abel> surely it will, esp. because most PHP programmers write for the
    Abel> internet and this usually requires ecmascript/javascript
    Abel> skills: it is familiar already.

But is it useful?

What will the programer be able to do that (s)he cannot do with
xsl:function?

If using the host language, I can envisage various answers, but Javascript?

One thing that I dearly miss from the XSLT spec is a way to do a POST request (i.e., retrieve a SOAP or JSON XML document through web services). With JavaScript one has the ability to use XmlHTTPRequest which can be used for issuing a POST to the server and returning an XML object.


Another thing you can do is check the existence of an external resource, i.e., if you use unparsed-text-available() the function will fully parse the text and will only fail or succeed. It won't say, for instance, that the UTF-8 contains invalid characters. I happen to work a lot with external resources. Knowing the difference between the availability of a URL and the unparsability of a URL is of great value to me.

And I'm sure there are other things that cannot be done through xsl:function. I.e., try to process a ZIP file will be rather hard (meaning: impossible) in XSLT because of the &#x0; characters.

-- Abel Braaksma

Current Thread