[xsl] How to report errors to stdout from xslt?

Subject: [xsl] How to report errors to stdout from xslt?
From: Don McClimans <dmcxslt@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 25 Jul 2004 08:51:07 -0400
I am using xslt as part of the build process for a C++ application, under Windows. I manually edit an xml file (it is the "source code"). As part of the build, the xml file gets run through various XSLT scripts that produce .rc and .h and .cpp files. Those files are then compiled into the application.

Right now, if there is a semantic error in the XML file, the script passes this along to the other files, and the error is caught by the compiler. This generates a compiler message which does not directly relate to the XML file. I would like to do more semantic checking in my XSLT script, and report the errors there.

What I would like to do in my xslt script is generate an error message to stdout, and then return an error code from the xslt processor, just as if the processor had detected an error. In the Visual C++ build environment, messages written to stdout from an external build tool are displayed in the build output window, just like error messages from the compiler itself. Also, if an external build tool returns a non-zero error code, the build is aborted. (By "returns", I mean returns an error level in the same sense as a batch file returning an error level).

Is there any way to do this? Or any other way to get similar functionality? I can use msxsl or xalan as the xslt processor. There is no problem using jscript or vbscript functions, though I am not well versed in using either scripting language.

Thanks for your help.


Current Thread