For background, you should at least skim-read the paper Transient Astronomy with ACP Scheduler (PDF) and focus on the XML Pre-Patching section.
The role of the pre-patcher is to fix up any illegal XML that might be present in incoming VOEvent messages. If left in the message, illegal XML will cause validation to fail and will result in the message being discarded by the receiver.
The pre-patcher can be any type of Windows command line program, written in any language. This includes Windows Script programs which run under the Windows command line script host cscript.exe, plus Perl and Python scripts which have their own execution engines. If the pre-patcher is an executable program, it can be written in any language which provides a command line interface and which supports reading from "standard in" and writing to "standard out" and "standard error".
The raw message XML is piped into the script or program’s standard input and the patched XML is expected to be written by the pre-patcher to its standard output. The receiver simply waits for the (external) pre-patcher program to exit before moving to the next phase of processing. The pre-patched XML is then fed to the receiver’s VOEvent parser/validator module, which contains its own pre-patching logic (see Transient Astronomy with ACP Scheduler).
Normally, when dealing with XML, one would feed the XML into an XML engine which parses the data and constructs a Document Object Model which can be manipulated. This is vastly preferable to picking through the raw XML text. However, in the pre-patcher it should be assumed that the incoming VOEvent XML is not valid and therefore cannot be parsed by an XML engine. Therefore, you are stuck with fixing up the raw XML data.
By far the most powerful tool for fixing up raw XML data is Regular Expressions. If you aren't familiar with regular expressions, you're at a serious disadvantage when writing your own pre-patcher. Virtually all programming languages and scripts include regular expression tools. It is beyond the scope of this document to describe regular expression programming.
If the pre-patcher program encounters an error and must exit unsuccessfully it is vital that it do both of the following:
You have control over your program's exit status value, and as you'll see below, the receiver will report the exit status value in its log and in a balloon popup if your program exits with any error status. Therefore, you can use the exit status value to help you isolate between sources of error within your program.
The Windows Script Host (cscript.exe) automatically does these two things. If your script fails to compile or if there is a fatal run-time error, cscript.exe puts all error text on its standard error and exits with non-zero status. The exit status value isn't too useful, but the error text is usually very useful.
The receiver's configuration settings provide for the path to the executable and command line arguments to be passed to the program (see diagram on the right). The receiver will invoke the pre-patcher program as follows: