logo       

RE: handling failed document() invocations: msg#01404

Subject: 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




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
region.costa-ri...    user-groups.lin...    lang.prothon.us...    xfree86.cvs/200...    finance.aqbanki...    ietf.smtp/1993-...    web.turbogears....    jakarta.cactus....    yellowdog.gener...    php.gtk+.genera...    org.region.indo...    hurd.l4/2005-10...    culture.religio...    apple.fink.gene...    db.mysql.window...    bluez.devel/200...    security.pgp-ba...    video.blender.d...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe