Re: [xsl] document() function - friendly error message when load fails

Subject: Re: [xsl] document() function - friendly error message when load fails
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Mon, 15 Jan 2007 15:49:20 +0100
Hi Ovidiu,

What a coincidence: for the past few days we happen to have being discussing this very thing (though, more generic, about URI escaping and wrong URI references), see More meaningful error for "Fatal error during transformation: null" on the Saxon list.

Alas, that is about XSLT 2. You use MSXML, thus limited to XSLT 1. And XSLT 1 does not provide such function (nor does XPath 1 for that matter).

You can use msxsl:script, I suppose. If it supports normal JavaScript of VBScript (I never used msxml), I reckon you can employ the XMLHttpRequest object to try to load the file. If it returns a 404 (or any 4xx error), it is not there and you can act accordingly. Note, however, that this requires two times requesting the file: 1x for the XHR, and 1x for XSLT document().

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

Ovidiu Cotarlea wrote:
1. Hi, Is there any way to catch the error that the
xslt function document() it's throwing when the resource specified
by the uri is not found?
My XML is rendered into HTML directly by Internet
Explorer 6 (MSXML 3.0).
It seems that the MSXML 3.0 in this case is not
returnig an empty node-set and it prefers the error message.


2. Did anyone tried to use <msxsl:script> </msxsl:script> to check if the resource is available?

Thanks,
Coti





___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Current Thread