Converting XML to HTML using XSL
Contents
What is xml2html?
xml2html is a Java program that converts XML files to HTML files
using XSL. As a command line program, xml2html can be used to convert
XML files that are rarely changed to HTML files. For XML files that
change more often, you can use xml2html as a servlet to convert files as
they are requested from a web server.
I'd like to know if anyone uses this, so please drop me a line here.
If you make any changes, please email the changes to me from here
- I'll consider them for inclusion in the main kit.
This program is very simple, so please spend quality time working out
problems on your own before contacting me. I can't promise when I'll
get back to anyone as I'm very busy; if you really think I can help you,
and you can wait, then email me from here.
If you choose to reuse the code, please acknowledge IBM's alphaWorks
and myself, Bob Hays.
How do I get
xml2html?
There are now two versions of the code. This version will work with LotusXSL V. 0.16.3, while this works with LotusXSL V. 0.16.5. Note that I couldn't get anything to parse right using IBM's most recent XML4J parser, V. 2.0.6; I either get failures to parse basic XML documents that don't contain DTDs and that used to parse correctly, or I get a missing xslns:xsl declaration when I have the tag there and it parsed properly before.
-
DOS/Windows: com\abnamro\infinity\servlet
-
UNIX: com/abnamro/infinity/servlet
Make sure you have all the required
pieces, and then recompile.
What
software will I need from the net to build and run it?
Here are links to all the things I think you need to run this:
-
LotusXSL: an
XSL processor from the IBM alphaWorks shop (they are very cool - give them
a look if you haven't before)
-
xml4j: IBM's XML
parser. You need version 1.1.14 or 2.0.3; I've used 1.1.14 for testing
(the LotusXSL kit includes 1.1.14, I think).
-
JSDK:
The Java Servlet Development Kit.
You need to get and install all this nice stuff to use xml2html.
How do
I run it as a program?
xml2html takes two arguments:
java com.abnamro.infinity.servlet.xml2html xmlfile xslfile
where:
-
xmlfile
-
A URL that points to an XML file
-
xslfile
-
A URL that points to the appropriate XSL file for the provided XML file
How do
I run it as a servlet?
Follow the instructions for your particular web server to install the servlet.
The command for xml2html as a servlet is:
http://yourhost/servlet/com.abnamro.infinity.servlet.xml2html?XML=xmlfile&XSL=xslfile
where:
-
xmlfile
-
A URL that points to an XML file
-
xslfile
-
A URL that points to the appropriate XSL file for the provided XML file