[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: handling failed document() invocations

Subject: RE: handling failed document() invocations
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 30 Oct 2002 11:21:33 -0000
RE:  handling failed document() invocations
> 
> The problem is there may not be a document there, which is an 
> OK state of affairs.  What is the xsl code idiom for 
> detecting when document() is unable to find a document at the 
> given location, and to handle this in a more meaningful way 
> than exiting on error?
> 
> If it matters I'm using saxon 6.5.2.
> 

The XSLT 1.0 spec says that the implementation can choose whether to
fail when document() can't find anything, or to recover by returning an
empty node-set. Unfortunately this doesn't really help you write
portable code.

In Saxon you can set the error handling options from the command line:

  -w0 recovers silently from recoverable errors
  -w1 (the default) gives a warning and then recovers
  -w2 gives a fatal error

You can also control it from the API.

This is a global switch that applies to all errors; you could also try
to write a JAXP ErrorListener that handles the specific error.

Another approach is to write your own URIResolver that finds the
document, it can return a dummy document if nothing is found. This is
probably the most portable solution.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.