I'm trying to execute saxon (XSLT command line parser) from VB.NET. From the DOS prompt, I have no problem doing so. However, my VB.NET application seems to refuse to work properly. Here's what I want to execute:
' Works in DOS
saxon -o output.xml input.xml transform.xsl 2>error.txt
Basically, the above command passes an input XML file and XSLT transformation script, defines the output file and sends any errors to standard output into error.txt.
Here's what I am trying to do in VB.NET
' Let's assume all these files are in the execution directory
Dim p as New System.Diagnostics.Process
p.StartInfo.FileName = "saxon.exe"
p.StartInfo.Arguments =" -o output.xml input.xml transform.xsl 2>error.txt"
p.StartInfo.RedirectStanda
rdOutput = True
p.StartInfo.UseShellExecut
e = False ' does this prevent the DOS window from showing?
p.Start
Dim a As String = p.StandardOutput.ReadToEnd
MesssageBox.Show(a) ' always shows null string even when something should be there
Also, the transformation does not occur when the arguements include "2>error.txt." If I remove that from the arguements, the transformation works just fine -- except now I don't have my error log.
What's the proper way to execute a command line application with arguements that send to the standard output?
Start Free Trial