CIS 97YT Index > Batch Files

CIS 97YT Batch Files

You may copy and paste the following code into batch files to make your work easier. Make sure that your batch files end with the extension .bat, and are 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.

wellformed.bat

echo off
java -cp f:\xmljar\xerces-2_0_0\xercesImpl.jar;f:\xmljar\xerces-2_0_0\xmlParserAPIs.jar;f:\xmljar\xerces-2_0_0\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)

echo off
java -cp f:\xmljar\xerces-2_0_0\xercesImpl.jar;f:\xmljar\xerces-2_0_0\xmlParserAPIs.jar;f:\xmljar\xerces-2_0_0\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 f:\xmljar\msv\msv.jar %1 %2

Note: If your XML document has an internal subset DTD, you may encounter errors of the form: Element type "mumble" must be declared. If so, use the following file instead. When you use this script, error messages will give line numbers and column numbers as before, but the column number will always be -1. That's why this is not the script I prefer to use.

echo off
java -jar f:\xmljar\msv\msv.jar -crimson %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)

echo off
java -cp f:\xmljar\xalan-j_2_3_0\bin\xml-apis.jar;f:\xmljar\xalan-j_2_3_0\bin\xercesImpl.jar;f:\xmljar\xalan-j_2_3_0\bin\xalan.jar org.apache.xalan.xslt.Process -IN %1 -XSL %2 -OUT %3 

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)

echo off
java -cp f:\xmljar\Fop-0.20.1\build\fop.jar;f:\xmljar\Fop-0.20.1\lib\batik.jar;f:\xmljar\Fop-0.20.1\lib\xalan-2.0.0.jar;f:\xmljar\Fop-0.20.1\lib\xerces-1.2.3.jar;f:\xmljar\Fop-0.20.1\lib\jimi-1.0.jar org.apache.fop.apps.Fop %1 %2 %3 %4 %5 %6 %7 %8

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