Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/19/2008
Times viewed :
5680
Xalan: Getting Started
Introduction
Xalan-J provides transformation API to convert XML into any other document
(XML, .TXT etc..) by applying XSLT stylesheet. Xalan-j fully supports XSL
Transformations (XSLT) Version 1.0 and the XML Path Language (XPath) Version
1.0. XSLT is the first part of the XSL stylesheet language for XML. It includes
the XSL Transformation vocabulary and XPath, a language for addressing parts of
XML documents.
XSLT stylesheets are well formed XML documents, they contains instructions to
convert XML document XML, HTML, XHTML or plain text. In structural terms, an XSL
stylesheet specifies the transformation of one tree of nodes (the XML input)
into another tree of nodes (the output or transformation result).
Example of XSLT:
Let’s look into the XML document
<?xml version="1.0" encoding="UTF-8"?>
<employee>
<employeename>test</employeename>
<employeeaddress>test123</employeeaddress>
<SSN>12343456</SSN>
<company>XYZ Corporation</company>
</employee>
I want to convert this XML document into a HTML document in a tabular format.
By default XALAN-J works with Xerces-Java but it can be configured to work
with any parsers.
Features of XALAN-JAVA
XALAN-JAVA contains XSLT processor for use in a tooling and debugging
environment and a Compiling processor (XSLTC) for use in a high performance
runtime environment.
Fully supports W3C provided XSLT1.0 and XPATH1.0
XALAN-JAVA implements TrAX. This transformation API for XML which in built
on SAX2 and SOM Level2.
XALAN-JAVA by default works with Xerces-java.
XALAN-JAVA can be configured to work with api XML Parser API.
Chaining mechanism can be used for transformation. E.g. output of one
transformation can be used an the input to another transformation.
XALAN-JAVA can be run from command line. Please look into the Process
document as a part of XALAN tutorial in topxml.com to know more details on
command line operation.
XALAN-JAVA can be used in server componet e.g. servlet to perform the
transformation.
Setting up your environment
The
very first thing you need to do is to set up your classpath to refer all jar
files provided with XALAN-java directory. include xalan.jar, xml-apis.jar, and
xercesImpl.jar -- or another conformant XML parser.
To
run the Xalan-Java Interpretive processor sample applications, include
xalansamples.jar (all samples other than the servlet) and xalanservlet.jar. To
run JavaScript extensions, include bsf.jar. All these JAR files are distributed
with Xalan-Java.
If
you are using JDK or JRE 1.2.2, 1.3.x or 1.4.x, include tools.jar on the
classpath. If you are using JDK or JRE 1.1.8 (supported for runtime only), then
include classes.zip on the classpath.
Please
go through this tutorial to enhance your understanding on transformation using
XALAN-java.