Re: [xslt] Exit code of xsltproc



On Thu, May 02, 2002 at 09:52:43AM +0200, Thomas Mauch wrote:
> Hello,
> I'm using xsltproc to transform XML document. To do this batchwise, I need to be able to detect whether the transformation was successful or not. Unfortunately, xsltproc seems to return 0 as well in the case of errors in the xslt-script where I think an error code should be returned:
> - If I just write some dummy text into the xslt-file, I get a compilation error (misplaced text element), but the exit code is 0

  Okay, I fixed this one:

paphio:~/XSLT/xsltproc -> xsltproc tst.xsl tst.xml
compilation error: file tst.xsl line 3 element text
misplaced text element: '

foo
'
paphio:~/XSLT/xsltproc -> echo $?
5
paphio:~/XSLT/xsltproc -> 

> - If pass an invalid value to the terminate attribute of xsl:message, I get an error message (xsl: message : terminate expecting 'yes' or 'no'), but the exit code is 0

  okay fixed this one too:

paphio:~/XSLT/xsltproc -> xsltproc tst.xsl tst.xml
xsl:message : terminate expecting 'yes' or 'no'
hello
<?xml version="1.0"?>
no
paphio:~/XSLT/xsltproc -> echo $?
9
paphio:~/XSLT/xsltproc -> 

> - On the other hand, other compilation errors (Opening and ending tag mismatch) seem to produce an exit code 9
> Is this behaviour by design or is just a bug?

  Sounds like bugs, I have tried to return error codes, but I certainly 
didn't catch all cases. It's probably not very hard to get to fix them, look
in the code where the message happen, and make sure the error is flagged in
the current style or processing context, then xsltproc will look at the
result and indicate this on the exit value automatically.

> Additionally, I would like to use xsl:message with the terminate=no to write warnings (and continue processing) and terminate=yes to write errors (and stop processing). As xsl:message writes to stderr, this should work fine. Unfortunately, an exit code of 0 is returned, even if the processing was stopped by a xsl:message instruction with terminate=yes. Wouldn't it be useful if an exit code other than 0 would be returned, if the processing was terminated that way (and only parts of the output document have already been created)?

  Okay, done too:

paphio:~/XSLT/xsltproc -> xsltproc tst.xsl tst.xml
failure
<?xml version="1.0"?>
no
paphio:~/XSLT/xsltproc -> echo $?
10
paphio:~/XSLT/xsltproc -> 

  Commited in CVS:

http://cvs.gnome.org/bonsai/cvsquery.cgi?module=libxslt&branch=HEAD&branchtype=match&dir=libxslt&file=&filetype=match&who=veillard&whotype=match&sortby=Date&hours=&date=explicit&mindate=05%2F02%2F02+05%3A08&maxdate=05%2F02%2F02+05%3A10&cvsroot=%2Fcvs%2Fgnome

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]