The Java API for XML Processing (JAXP) is for processing XML data using applications written in the Java programming language
这部分内容主要提纲挈领的讲讲JAXP,讲讲他的几个重要部分,基本的工作原理,还有重要的api。
这是几个重要的工厂
SAXParserFactory,
DocumentBuilderFactory, and TransformerFactory
--which give you a
SAXParser
, a
DocumentBuilder
, and an XSLT transformer
The factory APIs let you plug in an XML implementation offered by another vendor without changing your source code. 是这些工厂的重要之处。
几个重要的包:
javax.xml.parsers
: The JAXP APIs, which provide a common interface for different vendors' SAX and DOM parsers
org.w3c.dom
: Defines the
Document
class (a DOM) as well as classes for all the components of a DOM
org.xml.sax
: Defines the basic SAX APIs
javax.xml.transform
: Defines the XSLT APIs that let you transform XML into other forms
SAXParserFactory:用来获取一个Parser实例的。
SAXParser:定义了几个parser()函数,需要传入XML Source和handler的对象。
SAXReader:SAXParser wraps SAXReader(需要看看)
DefaultHandler,ContentHandler,ErrorHandler,DTDHandler ,EntityResolver
重要的package:
org.xml.sax:
org.xml.sax.ext
org.xml.sax.helpers
DOM APIs
通过DocumentBuilderFactory 获得一个DocumentBuilder的实例,再通过DocumentBuilder的实例来获得.Document的对象。
org.w3c.dom:
javax.xml.parsers :Defines the
DocumentBuilderFactory
class and the
DocumentBuilder
class, which returns an object that implements the W3C
Document
interface.
XSLT APIs
A source object can be created from a SAX reader, from a DOM, or from an input stream. Similarly, the result object is the result of the transformation process. That object can be a SAX event handler, a DOM, or an output stream.
javax.xml.transform: Defines the TransformerFactory
and Transformer
classes
javax.xml.transform.dom:
javax.xml.transform.sax:
javax.xml.transform.stream :


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