Using SAX Implementation in JDK

This section provides a tutorial example on how to use the SAX interface included in JDK 1.8, which actually uses SAX implementation provided by the org.apache.crimson package.

I have a simple program here,, to show what are the implementation classes provided JDK for the SAX interfaces:

 * Copyright (c) 2002-2018 All Rights Reserved.
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
class SAXClassChecker {
   public static void main(String[] args) {
      try {
         File x = new File(args[0]);
         SAXParserFactory f = SAXParserFactory.newInstance();
         SAXParser p = f.newSAXParser();
         DefaultHandler h = new DefaultHandler();
      } catch (ParserConfigurationException e) {
      } catch (SAXException e) {
      } catch (IOException e) {

If you compile and run this sample program in JDK (Java Development Kit), you will get:

herong> java SAXClassChecker hello.xml

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

 What Is SAX (Simple API for XML)

Using SAX Implementation in JDK

 SAX Content Handler Interface - SAX Interface Java Example

 SAX Parsing Pattern Example

 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 (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