XSLT Implementations in JDK

This section describes the Java implementation classes of XSLT in JDK. XSLT interfaces are defined in the javax.xml.transform package: TransformerFactory, Transformer, Source, Result. JDK 1.4 actually uses org.apache.xalan package for XSLT transformation.

JDK offers the following interfaces to support XSLT:

One thing seems to be missing here: who represents the transformation stylesheet? The answer is that the stylesheet will be read in when you instantiate a Transformer object.

I have a simple test program here, XSLClassChecker.java, to show what are the XSLT implementation classes included in JDK:

/* XSLClassChecker.java
 * Copyright (c) 2002-2018 HerongYang.com. All Rights Reserved.
import javax.xml.transform.Source;
import javax.xml.transform.Result;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
class XSLClassChecker {
   public static void main(String[] args) {
      try {
         TransformerFactory f = TransformerFactory.newInstance();
         Transformer t = f.newTransformer();
         Source s = new StreamSource();
         Result r = new StreamResult();
      } catch (TransformerConfigurationException e) {
      } catch (TransformerException e) {

Compile and run this example program with JDK (Java Development Kit):

herong> java XSLClassChecker

javax.xml.transform.TransformerException: Result object passed to
  ''{0}'' is invalid.

Note that:

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 XML-JSON Document Conversion

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

Java Implementation of XSLT

XSLT Implementations in JDK

 XSLTransformer.java - A Simple XSLT Transformation Program

 XSLT (XSL Transformations) Introduction

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

 PHP Extensions for XML Manipulation

 Processing XML with Python Scripts

 XML Notepad - XML Editor

 XML Tools Plugin for Notepad++

 XML Plugin Packages for Atom Editor

 XML 1.1 Changes and Parsing Examples

 Archived Tutorials


 Full Version in PDF/EPUB