xsl-list
[Top] [All Lists]

Re: [xsl] Saxon auto-recognition of sequence of XML and XSLT document possible ?

2007-02-05 03:18:44
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--