Magazine
 
XML- SAX Parser using JAXP API
 

(builds a DocumentBuilder).
TheDocumentBuilder further creates a DOMcompliant
document object.

The factory APIs enables to plug-in with the XML implementation (provided by any vendor without changing the source code). The obtained implementation depends on the setting of the system properties of these factory classes javax.xml.parsers.SAXParserFactory and javax.xml.parsers.DocumentBuilderFactory. The default values (unless overridden at runtime) point to the reference implementation.

In this section, you will learn how SAX Parser parses and get the information from the XML document.

The SAX Packages:
The SAX parser is defined in the following packages:

Package

Description

org.xml.sax

Defines the SAX interfaces. The name "org.xml" is the package prefix that was settled on by the group that defined the SAX API.

org.xml.sax.ext

Defines SAX extensions that are used when doing more sophisticated SAX processing, for example, to process a document type definitions (DTD) or to see the detailed syntax for a file.

org.xml.sax.helpers

Contains helper classes that make it easier to use SAX -- for example, by defining a default handler that has null-methods for all of the interfaces, so you only need to override the ones you actually want to implement.

javax.xml.parsers

Defines the SAXParserFactory class, which returns the SAXParser. Also defines exception classes for reporting errors.

Try to avoid using attributes in few of the situations.

Main classes of javax.xml.parsers package:

SAXParser

Defines the API that wraps an XMLReader implementation class

SAXParserFactory

Defines a factory API that enables applications to configure and obtain a SAX based parser to parse XML documents

Main interfaces of org.xml.sax package:

ContentHandler

Receive notification of the logical content of a document.

DTDHandler

Receive notification of basic DTD-related events.

EntityResolver

Basic interface for resolving entities.

ErrorHandler

Basic interface for SAX error handlers.

Feb 2008 | Java Jazz Up |26
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,

Download PDF