Re: [xsl] How do I set up my Saxon call to update/pass back a log file

Subject: Re: [xsl] How do I set up my Saxon call to update/pass back a log file
From: "Wolfgang Laun wolfgang.laun@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 17 Mar 2015 11:37:44 -0000
There's really no need to write a shell script or a Java program to have a
list of users notified when your Java call to execute a Saxon
transformation misbehaves.

When you edit the crontab job (crontab -e), include an environment
definition for variable MAILTO with a list of mail addresses, followed by
the crontab entry for calling Saxon. I'm using a script since this
simplifies tuning the details of the call:

MAILTO = cwilbur@xxxxxxxxxxx,jdoe@xxxxxxxxxxx,psmith@xxxxxxxxxxx
0 12 * * *    /home/auser/saxon/call.sh

The script should use redirection (*2>&1*):

#! /bin/bash
cd /home/auser/saxon
/extra/JDK8u20/jdk1.8.0_20/bin/java \
  -cp /extra/saxon/saxon9he.jar net.sf.saxon.Transform -s:call.xml
-xsl:call.xsl -o:call.csv 2>&1

Users will only receive mail if something is written to standard output or
standard error.

Cheers
-W



On 16 March 2015 at 18:01, Hank Ratzesberger xml@xxxxxxxxxxxx <
xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> Hi Catherine,
>
> do you mean the shell variable that is the status of the last executed
> command? ( $? in bash shell)
>
> This seems like a quick explanation:
>
> http://www.thegeekstuff.com/2010/03/bash-shell-exit-status/
>
> Sounds like you need to save the standard out and error to a log so
> you can evaluate the specific Saxon error:
>
> host# /usr/java5/bin/java ... &>out.log
>
> I can't find the errors that Saxon (through the java runtime) will
> return (maybe anything but 0), but the full error code, in the
> standard error output, is explained here:
>
>
> http://www.saxonica.com/html/documentation/javadoc/net/sf/saxon/trans/SaxonErrorCode.html
>
> You could have out.log mailed to you or grepped for the status.
> Otherwise, it would take a java class to configure Saxon and evaluate,
> as Michael suggests.
>
> HTH
>
> --Hank
>
> On Mon, Mar 16, 2015 at 6:47 AM, Catherine Wilbur cwilbur@xxxxxxxxxxx
> <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
> > Michael Kay (you indicated the following)
> >
> > Can you define "does not work properly"? Is it synonymous with "fails
> with a
> > dynamic error?
> >
> > Saxon does pass a simple return code back to the shell when a static or
> > dynamic error occurs, and of course it does allow you to redirect
> standard
> > error output to a file.
> >
> > But I'm afraid if I were attempting something like this, I wouldn't put
> the
> > logic in a shell script, I would put it in a Java application. Your
> mileage
> > may vary.
> >
> >
> > From the following call
> >
> >     /usr/java5/bin/java -cp $SAXON_JAR net.sf.saxon.Transform
> > -s:$FinesrvDataDir/Library_Invoice_Interface.xml
> > -xsl:$FinesrvCronDir/LibrXML2CSV_stylesheet.xsl
> > -o:$FinesrvDataDir/Library_Invoice_Interface.csv
> >
> > Would like to pass an error back to my shell script.  The error would be
> > because we did not code something properly or the fact we made an
> assumption
> > regarding the XML file and now that section that was supposed to appear
> at
> > least once does not exist (that is what happened).  We submit all of our
> > production using cron jobs using shell scripts so they want me to trap
> the
> > error in my shell script and send a message out to the individuals that
> need
> > to look at fixing the problem.  I would not even know how to set up a
> Java
> > application to set this up.  Have written Java code for batch programs
> but I
> > am just a novice in this area.  Would be very interested in learning how
> to
> > set it up in a Java application.
> >
> > So was wondering how to set up the Saxon call so I can pass a log file
> back
> > and a return code.    If an error appears then I need to send out a msg.
> > Searched the web for the options available from net.sf.saxon call.
> > _____________________________________________________________________
> > Catherine Wilbur  |  Senior Application Programmer  |  IT Services
> > 401 Sunset Avenue, Windsor ON Canada  N9B 3P4
> > (T) 519.253.3000 Ext. 2745  |  (F) 519.973.7083  |  (E)
> cwilbur@xxxxxxxxxxx
> > www.uwindsor.ca/its
> > XSL-List info and archive
> > EasyUnsubscribe (by email)
>
>
>
> --
> Hank Ratzesberger
> XMLWerks.com

Current Thread