Download version 2.4.1
Download examples (ZIP format)
This product includes software developed by the
Apache Software Foundation
(http://www.apache.org/).
In her Visual Quickstart Guide to XML for the World Wide Web (ISBN 0-201-71098-6), Elizabeth Castro remarked that she was looking for an XSLT processor for the Macintosh. I realized that Xalan, written in Java by the Apache Software Foundation, might provide just such a processor.
The most appropriate sample program for the task was SimpleTransform.java in the Xalan distribution. It is designed to run from a command line, but the Macintosh operating system (before OS X, that is) does not provide such a command line. I took the SimpleTransform.java program and added some code to make it into an XSLT processor that would allow easy testing of XML and XSL files.
You may download the first two items in the list from Apple Computer's website; the URL is http://devworld.apple.com/java/text/download.html
Although Apple recommends 40MB of memory to run Java, I have tested this software on a Performa 6320CD running Mac OS 8.5 with 32MB of memory and 38MB of virtual memory.
For your convenience, xerces.jar and xalan.jar have been included with this distribution. You may download the latest version of the jar files and the source from the Apache Software Foundation.
The original version worked with an older version of the Xalan and Xerces packages. Thanks to Andrew Steeley, there is now a newer version that works with Xalan version 2.4.1.
If you don't already have the Macintosh Runtime for Java installed, you'll need to install it according to the instructions along with that package. The SDK (Software Development Kit) is definitely necessary if you want to modify this code. I haven't tested it without the SDK installed, so I highly recommend that you install it as well, again, according to their instructions.
This package contains the following files:
IMPORTANT: Xalan and Xerces don't like blanks in file names. The path to the location where you've installed MacXSLT may not contain any blanks! Thus:
MyDisk:XML-experiments:MacXSLT | Works fine - no blanks |
My Disk:XML-experiments:MacXSLT | Bad - has blanks |
MyDisk:XML experiments:MacXSLT | Bad - has blanks |
The easiest way to learn how to use MacTransform is to do these examples. The files that the first example uses are simple.xml and simple.xsl in the examples folder. Please take a look at them before you proceed.
Get file names from saved parameter list (ENTER for none) >
XML file name > examples/simple.xml
XSL file name > examples/simple.xsl
Output file name [ENTER alone for screen] > examples/simple.output
Transforming examples/simple.xml using examples/simple.xsl with output to examples/simple.output...
...finished
Type name of file to save parameters in, or just press ENTER > examples/simple.parameters
Get file names from saved parameter list (ENTER for none) > examples/simple.parameters
XML file: examples/simple.xml
XSL file: examples/simple.xsl
Output file: examples/simple.output
Transforming examples/simple.xml using examples/simple.xsl with output to examples/simple.output...
...finished
Type name of file to save parameters in, or just press ENTER >
In your favorite text editor, open simple.parameters in the example folder (it's the file we created in step 8 above). Here's what it looks like:
# # Generated by MacTransform # xmlFileName = examples/simple.xml xslFileName = examples/simple.xsl outputFileName = examples/simple.output
For those of you who are familiar with Java, this is just a standard properties file.
Now, open up the catalog.parameters file in the example folder (it has been created for you):
# # Example parameter file; provides the XML file name, but prompts # you for the XSL and output file names # xmlFileName = examples/catalog.xml xslFileName = outputFileName =
MacTransform works as follows: if a file name is not specified in a parameter file, it will prompt you for that filename. This parameter file will let you specify the XSL and output files to use when processing examples/catalog.xml.
Now, let's use this parameter file to do two different conversions on the catalog.xml file. Before proceeding, open catalog.xml in a text editor to see what it looks like.
Get file names from saved parameter list (ENTER for none) > examples/catalog.parameters
XML file: examples/catalog.xml XSL file name > examples/catalog1.xsl
Output file name [ENTER alone for screen] > examples/catalog1.html
Transforming examples/catalog.xml using examples/catalog1.xsl with output to examples/catalog1.html... ...finished Type name of file to save parameters in, or just press ENTER > examples/catalog1.params
Transform another file? (Y/N) > y
Get file names from saved parameter list (ENTER for none) > examples/catalog.parameters
XML file: examples/catalog.xml XSL file name > examples/catalog2.xsl
Output file name [ENTER alone for screen] > examples/catalog2.html
Transforming examples/catalog.xml using examples/catalog2.xsl with output to examples/catalog2.html... ...finished Type name of file to save parameters in, or just press ENTER > examples/catalog2.params
Run MacTransform again. Use examples/catalog.xml as your XML file, examples/catalog3.xsl as the XSL file, and send output to examples/catalog3.rtf. You may use the examples/catalog.parameters file to make your work a little easier. Open examples/catalog3.rtf in your favorite RTF-aware word processor.
If you edit or construct your own parameter files, and you want the program to prompt you for a filename, make sure you just erase everything after the equal sign. Do not erase the entire line; otherwise MacTransform will tell you that your parameter file isn't valid.
If you want the output to go to the screen, the last line in the file should read:
outputFileName = $CONSOLE