CIT041X Index > Batch Files

CIT041X Batch Files

You may copy and paste the following code into batch files to make your work easier. Your batch files must end with the extension .bat, and must be plain text files! Do not just create a Microsoft Word document with the commands in them; that won't work. If you insist on using Microsoft Word, you must save the resulting file as plain text, and make sure that Word doesn't “helpfully” add a .doc or .txt extension for you.

Note: these are long lines; make sure you copy the entire line, not just the part that is visible on the screen without scrolling horizontally!

wellformed.bat

Copy these two lines:

echo off
java -cp h:\java\xmljar\xerces-2_6_2\xercesImpl.jar;h:\java\xmljar\xerces-2_6_2\xmlParserAPIs.jar;h:\java\xmljar\xerces-2_6_2\xercesSamples.jar dom.Counter %1

To check to see if file testfile.xml is well-formed, you'd type this at the command prompt:

wellformed testfile.xml

validate.bat (DTDs)

Copy these two lines:

echo off
java -cp h:\java\xmljar\xerces-2_6_2\xercesImpl.jar;h:\java\xmljar\xerces-2_6_2\xmlParserAPIs.jar;h:\java\xmljar\xerces-2_6_2\xercesSamples.jar dom.Counter -v %1

To check to see if file testfile.xml is valid, you'd type this at the command prompt:

validate testfile.xml

msvalidate.bat (Relax NG)

echo off
java -jar h:\java\xmljar\msv\msv.jar %1 %2

To check to see if file testfile.xml is valid with respect to the Relax NG specified in file testfile.rng, you’d type this at the command prompt:

msvalidate testfile.rng testfile.xml

transform.bat (XSLT)

Copy these two lines:

echo off
java -cp h:\java\xmljar\xalan-j_2_6_0\bin\xml-apis.jar;h:\java\xmljar\xalan-j_2_6_0\bin\xercesImpl.jar;h:\java\xmljar\xalan-j_2_6_0\bin\xalan.jar;. org.apache.xalan.xslt.Process -IN %1 -XSL %2 -OUT %3 %4 %5 %6 %7 %8 %9

To transform a source file testfile.xml with the XSLT specified in file test_transform.xsl and place the output in file newfile.xml, you'd type this at the command prompt:

transform testfile.xml test_transform.xsl newfile.xml

fop.bat (Formatting Objects to PDF)

Copy these two lines:

echo off
java -cp h:\java\xmljar\fop-0.20.5\build\fop.jar;h:\java\xmljar\fop-0.20.5\lib\batik.jar;h:\java\xmljar\fop-0.20.5\lib\xalan-2.4.1.jar;h:\java\xmljar\fop-0.20.5\lib\xercesImpl-2.2.1.jar;h:\java\xmljar\fop-0.20.5\lib\xml-apis.jar;h:\java\xmljar\fop-0.20.5\lib\avalon-framework-cvs-20020806.jar;h:\java\xmljar\fop-0.20.5\lib\jimi.jar org.apache.fop.apps.Fop %1 %2 %3 %4 %5 %6 %7 %8 %9

To transform an XSL-Formatting Objects file testfile.fo to the PDF file testfile.pdf, you'd type this at the command prompt:

fop testfile.fo testfile.pdf

To transform an XML file testfile.xml directly to PDF file testfile.pdf using transformation transform.xsl, you’d type this at the command prompt:

fop.sh -xml testfile.xml -xsl transform.xsl -pdf testfile.pdf