"compile" and open resulting file?

General questions about using TextPad

Moderators: AmigoJack, helios, bbadmin, Bob Hansen, MudGuard

Post Reply
User avatar
rsperberg
Posts: 35
Joined: Thu Jul 29, 2004 2:26 pm
Location: NJ

"compile" and open resulting file?

Post by rsperberg »

The examples for tools all describe compilers, but I'm actually using an xslt transform on an xml file.

I have the Microsoft msxsl engine set up as a tool.

If I provide the output parameter and filename, the resulting transformation is saved as a file.

If I omit it, the resulting transformation shows up in the Command Results window. In that case, I need to save the file manually.

What I'd like to do is provide a filename and have the file created and saved for me, but I'd like TextPad to open that file in a new window so I can look at it.

Is there any way to do this?

Thanks,

Roger Sperberg
User avatar
talleyrand
Posts: 625
Joined: Mon Jul 21, 2003 6:56 pm
Location: Kansas City, MO, USA
Contact:

Post by talleyrand »

Perhaps a .bat file is the tool you could use to acomplish this?

It'd look something like

c:\program files\microsoft something\bin\msxsl.exe %1 %2
C:\program files\textpad 4\textpad.exe %2
I choose to fight with a sack of angry cats.
User avatar
rsperberg
Posts: 35
Joined: Thu Jul 29, 2004 2:26 pm
Location: NJ

Error messages?

Post by rsperberg »

I won't be able to try this out for a while. Thanks for the suggestion.

I wonder what will happen if there's an error in the transformation -- will it be delivered to the Command Results window do you think?

When I provide the -o filename parameter, saving the transformation into a file, errors do show up in Command Results, which obviously is helpful.

Thanks again,

Roger
User avatar
rsperberg
Posts: 35
Joined: Thu Jul 29, 2004 2:26 pm
Location: NJ

Got it to work

Post by rsperberg »

Thanks for this guidance. You got me to the desired result.

I put the batch file in c:\programs, which I like to use for TextPad tools because it eliminates the issue of having a space in a directory name.

Then I found I couldn't call TextPad from the batch file because cmd.exe didn't like the space in the folder name. I'm sure there's some way to use spaces, but to get it to work I just made the batch file read like this:
c:\programs\msxsl.exe %1 %2 %3 %4
c:\Progra~1\TextPa~1\TextPad.exe %4
I set up the tool as a DOS command with these settings:
Parameters: c:\programs\msxsl-transform.bat $Filename my-stylesheet-name.xsl -o $Basename.xtmm
Initial folder: $FileDir

Regular expression to match output:

^(URL: file:///)([A-Z]:.+)\/(.+)\nLine:( *)([0-9]+)\nColumn: ([0-9]+)$

Registers:
File: 3 Line: 5 Column: 6
(The stylesheet name is hardwired into this, but of course that can be specified in the XML file being transformed.)

The batch file sent back information to the Command Results window when things went well and TextPad opened the results file and made it the active window.

When I ran it with a non-well-formed XML file, the Command Results window display showed the error from the XSL engine and double-clicking on the file error line jumped me properly back to the source XML file.

(As noted in a different thread, I cannot get the Line and Column to work with this multi-line error message. Don't know if it's the regex or TextPad that's accountable.)

Roger
Post Reply