Hello Michael,

that's again just what I needed, works as expected;-)

Many thanks & best regards
Roman



From:        Michael Kay <mike@saxonica.com>
To:        Mailing list for the SAXON XSLT and XQuery processor <saxon-help@lists.sourceforge.net>,
Date:        01.08.2014 10:37
Subject:        Re: [saxon] Catching xsl terminations




Message output is sent to the registered MessageListener rather than to the ErrorListener. The MessageListener is a bit more complicated because in general, xsl:message outputs XML rather than plain text.

Michael Kay
Saxonica
mike@saxonica.com
+44 (0) 118 946 5893




On 1 Aug 2014, at 08:29, Roman Manz <RManz@amadeus.com> wrote:

Hi all,

you have advised me recently to use an ErrorListener to catch validation errors which works perfectly well.

Now I have a case where the xsl transformation fails and the ErrorListener does not seem to kick in.


Here is the stack trace:

net.sf.saxon.expr.instruct.TerminationException
: Processing terminated by xsl:message at line 461 in
       at net.sf.saxon.expr.instruct.Message.processLeavingTail(
Message.java:230)
       at net.sf.saxon.expr.instruct.Choose.processLeavingTail(
Choose.java:758)
       at net.sf.saxon.expr.instruct.Choose.processLeavingTail(
Choose.java:758)
       at net.sf.saxon.expr.instruct.Choose.processLeavingTail(
Choose.java:758)
       at net.sf.saxon.expr.instruct.Block.processLeavingTail(
Block.java:569)
       at net.sf.saxon.expr.instruct.Template.expand(
Template.java:225)
       at net.sf.saxon.expr.instruct.CallTemplate.process(
CallTemplate.java:284)
       at net.sf.saxon.expr.instruct.CallTemplate.processLeavingTail(
CallTemplate.java:308)
       at net.sf.saxon.expr.instruct.Block.processLeavingTail(
Block.java:569)
       at net.sf.saxon.expr.instruct.Template.expand(
Template.java:225)
       at net.sf.saxon.expr.instruct.CallTemplate.process(
CallTemplate.java:284)
       at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(
ForEach.java:388)
       at net.sf.saxon.expr.instruct.Instruction.process(
Instruction.java:123)
       at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(
ElementCreator.java:318)
       at net.sf.saxon.expr.instruct.ElementCreator.processLeavingTail(
ElementCreator.java:269)
       at net.sf.saxon.expr.instruct.Template.applyLeavingTail(
Template.java:208)
       at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(
ApplyTemplates.java:371)
       at net.sf.saxon.trans.StringifyRuleSet.process(
StringifyRuleSet.java:54)
       at net.sf.saxon.expr.instruct.ApplyTemplates.applyTemplates(
ApplyTemplates.java:353)
       at net.sf.saxon.Controller.transformDocument(
Controller.java:1887)
       at net.sf.saxon.Controller.transform(
Controller.java:1737)
       at com.amadeus.ade.cmdb.yacaupload.translator.xsltboy.__translate(
xsltboy.java:116)
       at com.amadeus.ade.cmdb.yacaupload.translator.xsltboy.translate(
xsltboy.java:65)
       at com.amadeus.ade.cmdb.yacaupload.uploadExecutor.upload(
uploadExecutor.java:110)
       at com.amadeus.ade.cmdb.yacaupload.uploadExecutor.run(
uploadExecutor.java:42)
       at java.lang.Thread.run(Unknown Source)


The xsl termination message looks like:

Sorry, the standby-type L3 Test does not match either of 'EHA|Disaster Recovery|Data Recovery|Reporting'.

; SystemID: ; Line#: 450; Column#: -1


The code:

               uploadXmlErrorListener el = new uploadXmlErrorListener();

               try {

                       env = env.replaceAll("[0-9]", "");

                       in = source.getInputStream();

                       xslt = new URL(getXsltUrl(altpath + "xsltboy.properties", alias, env)).openStream();

                       Configuration tfcfg = Configuration.makeLicensedConfiguration(null, "com.saxonica.config.EnterpriseConfiguration");

                       tfcfg.setSchemaValidationMode(Validation.LAX);                        

                       TransformerFactory tff = new TransformerFactoryImpl(tfcfg);

                       tff.setAttribute(FeatureKeys.SCHEMA_VALIDATION, Validation.LAX);

                       tff.setAttribute(FeatureKeys.USE_XSI_SCHEMA_LOCATION, true);

                       tff.setAttribute(FeatureKeys.XSLT_SCHEMA_AWARE, true);

                       Transformer tf = tff.newTransformer(new StreamSource(xslt));

                       tf.setErrorListener(el);

                       // here goes the parameter that can be passed into the transformation

                       // tf.setParameter("action", "update");

                      fos = new FileOutputStream(new File(outputfilename));

                       tf.transform(new StreamSource(in), new StreamResult(fos));

               } catch( Exception e ) {

                       e.printStackTrace();

                       throw new uploadException(el.getMsg());

               } finally {

...


Could you please explain me what I have to do in order to get hold of the termination message?


Many thanks! & best regards

Roman



IMPORTANT  -  CONFIDENTIALITY  NOTICE  - This e-mail is intended only for the use of the individual or entity shown above as addressees. It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws.  If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited.  If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system.

Amadeus Data Processing GmbH
Geschäftsführer: Dr. Wolfgang Krips
Sitz der Gesellschaft: Erding
HR München 48 199
Berghamer Strasse 6
85435 Erding
Germany
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.

http://p.sf.net/sfu/bds____________________________________________ ___
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help
------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds_________ _________________________ _____________
saxon-help mailing list archived at
http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help




IMPORTANT  -  CONFIDENTIALITY  NOTICE  - This e-mail is intended only for the use of the individual or entity shown above as addressees. It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws.  If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited.  If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system.

Amadeus Data Processing GmbH
Geschäftsführer: Dr. Wolfgang Krips
Sitz der Gesellschaft: Erding
HR München 48 199
Berghamer Strasse 6
85435 Erding
Germany