echo off
REM This is the batchfile-variant of generating XMI from some headers using manually callings (not ANT).
REM The advantages in respect to the ANT variant is: it is straight, you can see what is execute.
REM The ANT-variant is indirect. You don't see what should happen in a simple way.

REM set the position of file system where the other necessary download tools for XSL-translation are located:
set XML_TOOLS=/Progs/XML_Tools


REM set the environment variable to find batch-, zbnf- and xsl-scripts

set ZBNFJAX_HOME=..\..\zbnfjax

REM set the classpath to all necessary jars:
REM The zbnf.jar is necessary for org.vishia.zbnf.Zbnf2Xml.
set CLASSPATH=../../zbnfjax/zbnf.jar

REM The xslt.jar is necessary for org.vishia.xml.Xslt. Xslt is an enhanced XSLt-translator using saxon internally.
set CLASSPATH=%CLASSPATH%;../../zbnfjax/xslt.jar

REM The saxon8.jar is downlaodable from http://www.saxonica.com or http://sourceforge.net/projects/saxon
set CLASSPATH=%CLASSPATH%;%XML_TOOLS%/saxon9.jar;%XML_TOOLS%/saxon9-jdom.jar

REM The jdom is necessary because the input process use jdom, download it from http://www.jdom.org
set CLASSPATH=%CLASSPATH%;%XML_TOOLS%/jdom.jar

if not exist tmp mkdir tmp

REM All headers should be parsed with one java call per header like:
echo parsing Mystruct.h
java org.vishia.zbnf.Zbnf2Xml -i:Mystruct.h -s:%ZBNFJAX_HOME%/zbnf/Cheader.zbnf -y:tmp/Mystruct.h.xml -a:@filename="Mystruct" --report:tmp/Mystruct.zbnf.rpt

REM All parsed headers can transform via XSLT-2 using saxon in 2 steps.
echo building XMI
java org.vishia.xml.Xslt -itmp/Mystruct.h.xml -t%ZBNFJAX_HOME%/xsl/CheaderTypes.xsl -w+ -ytmp/test.types.xml
java org.vishia.xml.Xslt -itmp/Mystruct.h.xml -itmp/test.types.xml -t%ZBNFJAX_HOME%/xsl/gen/Cheader2Xmi.xsl -w+ -ytest.xmi

pause
