View Single Post
  #5 (permalink)  
Old August 24th, 2006, 10:49 AM
mhkay's Avatar
mhkay mhkay is offline
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

With Saxon (or any JAXP processor) you can define a URIResolver, which is a simple Java class that is called to process any URI passed to the document() function. In your URIResolver you can call the XML parser, and trap any error that it reports. If the document is OK you can return it, if it's not OK you can return a dummy document containing the error information. You don't have to parse the document twice, because you can return the parsed document tree as the response from the URIResolver if parsing is successful.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
Reply With Quote