TNO - Kennis voor zaken
 
 
 
 
 

Introduction
The example worked out on this page is based on the following capabilities:

  • Windows 2000 Professional as the operating system
  • An installed version of JRE 1.4 (full name: Java Runtime Environment from Java 2 SDK, Standard Edition (J2SE), v 1.4.1_01)
  • Xalan Java2 parser for XML and XSL style sheets

This step-by-step example is only intended as an illustration of how to parse files and has therefore been restricted to this configuration by necessity. There are innumerable ways to run a computer, such as MacOSX, Linux, Solaris, Windows, just to name a few, and there are also countless products on the market for parsing XML files, Xalan for Java being just one.

Installing Java
At the Command Prompt (the "DOS box"), type:

java -version

In this configuration, one of the choices that appears will be:

java version "1.4.1_01"

If the message "java is not recognized as an internal or external command, operable program or batch file" appears, then JRE is not installed. Follow the steps outlined below. Otherwise, skip to the Xalan heading.

Installing the Java JRE
In your browser:

  • Go to the Java Archives page at SUN and click on the link under the Java 2 SDK, Standard Edition (J2SE) heading from the 1.4 series
  • On the next page, select "Windows" and "JRE"
  • At the bottom of the page, click on "Accept"
  • Save the installation file

In Windows Explorer:

  • Go to the directory in which the installation file is saved and initiate installation by opening the file
  • Follow the standard instructions (clicking on "Next" when prompted) and Java Runtime Environment 1.4 will be installed on your computer

At the Command Prompt, type

set CLASSPATH=%CLASSPATH%;[insert the path to the JRE 1.4 directory]\lib\tools.jar

Xalan
In your browser:

    Go to xml.apache.org and select Xalan Java 2
  • Select "Downloads" from the links menu
  • Click on the link to "xalan-j distribution directory"
  • Select a link that ends in ".zip" and save the installation file

In Windows explorer:

  • Go to the directory in which the installation file is saved and unzip it
  • Save the contents of the Zip file; the contents will be saved to the Xalan installation directory

At the Command Prompt, type:

set CLASSPATH=%CLASSPATH%;[insert the path to the Xalan installation directory]\bin\xml-apis.jar;
set CLASSPATH=%CLASSPATH%; [insert the path to the Xalan installation directory]\bin\xercesImpl.jar;
set CLASSPATH=%CLASSPATH%;[insert the path to the Xalan installation directory]\bin\xalan.jar;

You can also insert the paths all at once but that could not be reproduced here because it would be unreadable

You are ready!

Parsing
You need the following:

  • A source file (an XML file from a boring, such as boring50E0403.xml)
  • A style sheet, in this case Profile of a Borehole
  • To save the boring and the style sheet in the same directory (not absolutely necessary but otherwise the following command will not work)

At the Command Prompt, go to the directory in which the boring is saved and type (on a single line):

java org.apache.xalan.xslt.Process -in boring50E0403.xml -xsl BoringenProfiel.xsl -out boring50E0403.html -HTML -INDENT 20

You can now open the file that was generated, boring50E0403.html, in your browser

Email: info@dinoshop.nl