[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Saxon auto-recognition of sequence of XML and XSLT

Subject: Re: Saxon auto-recognition of sequence of XML and XSLT document possible ?
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 02 Feb 2007 14:59:26 +0100
Re:  Saxon auto-recognition of sequence of XML and XSLT
Ben Stover wrote:
I want to create a DOS batch file onto I can drag TWO documents simultaneously:
ONE XML source and ONE XSLT sheet.


The key command in this batch file will be similar to

java -jar saxon8.jar "%1" "%2" .....

It now occurs from time to time that the XSLT stylesheet will be the first parameter %1
and the second  %2 represents the XML doc.

Is there no Auto-recognition from Saxon to detect which of the two documents is the
XML and which the XSLT stylesheet and hence allow also

java -jar dir/saxon8.jar [options] stylesheet source-document [ params...]

Maybe I have to pass another option?

There is no sense in 'auto-sensing' from Saxon's point of view, as XSLT itself is XML and can be used as the source for another XSLT document (which I often do).


However, in cases where only a specific type of calling convention is used (you seem to always have one *.xslt and one *.xml document and the second is the source for the first, correct?), you can use simple DOS Batch techniques.

Since you seem to already know how to work with DOS, you only have to change the following batch example to fit your needs. It uses a "trick" by exploring the errorlevel return code of the findstr dos utility (which is '1' when string is not found). Basic piping and trashing to the bin (nul) is used for making it a non-obtrusive simple command (third line below). You may have to change the findstr command a bit, for instance if you have *.xsl instead of *.xslt, or if you call it with quotes around it etc. Findstr supports regexes, check findstr /? for how.

The rest if the commands follow common msdos batch file logic with if/goto/label etc. Change "saxon" (which is on my path) to the way you call saxon.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

@echo off

REM The pipeline and %1 may not have a space between!
echo %1| findstr /E /C:.xslt >nul

if ERRORLEVEL 1 goto XMLFIRST
goto XMLSECOND

REM The XML file is the first argument, this is normal
:XMLFIRST
echo XMLFIRST
echo saxon %1 %2
saxon %1 %2
goto END

REM The XML file is the second argument, switch them
:XMLSECOND
echo XMLSECOND (switch back)
echo saxon %2 %1
saxon %2 %1
goto END


:END


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.