PDA

View Full Version : Capturing XSLT Error


Joseph McGarvey
12-31-2003, 10:11 PM
Is it possible to capture an XSLT error, much like a TRY/CATCH in Javascript? I have an xsl template that is looking at an XML file for a node value. If the XML file being requested does not exist, the page errors, since it cannot find the needed node. I want to capture this error and have the page do something else.

Example:
<xsl:value-of select='document(concat($global.path,@site,"/",@loc,"/",@page,".xml"))/page/Target'/>

If this XML file is found... no problem. If the XML file does not exist, write:

<xsl:value-of select='//errorText'/>

Thanks in advance!

M@rco
01-05-2004, 10:30 PM
Unfortunately, AFAIK that's simply not possible. The only thing I can think of is to pre-parse the input XML using a suitable server-side scripting language (such as ASP in combination with the Microsoft XML DOM component), determine the validity of the external resources, and modify the XML document accordingly, before transforming it with the XSLT stylesheet.