[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: Mon, 05 Feb 2007 11:17:03 +0100
Re:  Saxon auto-recognition of sequence of XML and XSLT
Florent Georges wrote:
echo %1| findstr /E /C:.xslt >nul
if ERRORLEVEL 1 goto XMLFIRST
goto XMLSECOND

Works with no one of my stylesheets. But once again, it is maybe
what the OP was looking for, we just don't know from its requirements.

I meant to refer to my original message. This is just a snippet, where you still have to create the instructions under the labels XMLFIRST and XMLSECOND. The following line:


echo %1| findstr /E /C:.xslt >nul

does the trick for determining whether the first command parameter ends with ".xslt". It is not easy to match if there are quotes involved, but remove "/E" and it will match any part in the first parameter. If you do use "/E", make sure there is no space between "%1" and "|". Also, of course, if your stylesheets are named ".xsl", change the line to:

echo %1| findstr /E /C:.xsl >nul

Here's a copy of the whole batch file for clarity.

@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 Xml file is first argument
echo saxon %1 %2
saxon %1 %2
goto END

REM The XML file is the second argument, switch them
:XMLSECOND
echo Xml file is second argument, switching arguments
echo saxon %2 %1
saxon %2 %1
goto END

:END

It works on Windows and solves the following commandlines, but you need more logic if you want to insert more parameters (because %1 will not be a file anymore, but a commandline switch):

saxon somesource.xml somestylesheet.xslt
saxon somestylesheet.xslt somesource.xml

does not solve (etc):
saxon -it main somestylesheet.xslt

It would be nice if the OP would answer with what he/she wants.

-- Abel

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

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-2007 All Rights Reserved.