|
Subject: Re: [xsl] How to recover/continue from XML Transformation exception? From: Jack Bush <netbeansfan@xxxxxxxxxxxx> Date: Wed, 24 Nov 2010 04:11:45 -0800 (PST) |
Hi Michael,
Apologies for having taking a while to respond due to other
commitments.
I have taken on board 2 (first & last) while staying with Saxon
9.1 and they
appear to be working after some preliminary testing on limited
set of data.
Much appreciated for your advice again,
Jack
----- Original
Message ----
From: Michael Kay <mike@xxxxxxxxxxxx>
To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Wed, 17 November, 2010 8:12:36 PM
Subject: Re: [xsl] How to recover/continue from XML Transformation exception?
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
>
>
>
>
> --~------------------------------------------------------------------
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
> To
unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or
e-mail:<mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --~--
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] How to recover/continue f, Michael Kay | Thread | [xsl] Was it a bug?, Frederic Bergeron |
| Re: [xsl] Select Data for individua, David Carlisle | Date | [xsl] xslt test automation, Bernhard Wagner |
| Month |