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

Re: How to recover/continue from XML Transformation e

Subject: Re: How to recover/continue from XML Transformation exception?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Wed, 17 Nov 2010 09:12:36 +0000
Re:  How to recover/continue from XML Transformation  e
It's not entirely clear from your question, but if you are calling transformer.transform() once for each XML file to be processed, you can catch the Java exception and continue.

for(Source source : sources) {
   try {
      transformer.transform(source);
   } catch (TransformerException err) {
      System.err.println("This one failed");
   }
}

On the other hand, if you are calling transform() once to process all the XML files, you will need to use an XSLT try/catch. This is available in XSLT 3.0 (aka 2.1), and implemented in Saxon 9.3: you will need the commercial edition.

Incidentally, if you are using the same stylesheet to process many files, I recommend reusing the JAXP Templates object, but creating a new Transformer object for each transformation.

Michael Kay
Saxonica


On 17/11/2010 07:44, Jack Bush wrote:
Hi All,
I have an Java application that continually transforms a single XML file at a
time which would fail every now and then, possibly due to corrupted data (not an
issue). However, the transformation process below using Saxon 9.1 would crashed
completely:
Transformer transformer = transformerFactory.newTransformer(new
StreamSource(StyleSheet));
JDOMSource areaSource = new JDOMSource(OriginaljdomXMLDocument);
JDOMResult areaResult = new JDOMResult();
transformer.transform(source, result);
As a result, is it possible to recover/continue from ad-hoc XML transformation?
If so, how could this be done?
Thanks a lot,
Jack

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.