Datasheet
The following set of methods deals with the DOCTYPE declaration:
Method Description
String getDoctypePublic() Gets the public ID of the current DOCTYPE.
String getDoctypeSystem() Gets the system ID of the current DOCTYPE.
void setDocType(String publicId, String systemID) Sets the public ID and system ID of the cur-
rent DOCTYPE.
38
Chapter 1
One least caveat on the use of the serializers: serializers aren’t thread safe, so
you have to be careful if you’re going to use them in a multithreaded
environment.
At the time of this writing, the W3C DOM Working Group is working on the DOM Level 3 Load/Save
specification, which includes a mechanism for saving a DOM tree back to XML. This work has not been
finalized and applies only to DOM trees. It’s definitely worth learning the Xerces serializers API, because
they also work with SAX. It’s also worthwhile because the current (experimental) implementation of
DOM Level 3 serialization in Xerces is based on the org.apache.xml.serialize classes.
XNI
The first version of Xerces used a SAX-like API internally. This API allowed you to build both a SAX API
and a DOM API on top of a single parser engine. For Xerces version 2, this API was extended to make it
easier to build parsers out of modular components. This extended and refactored API is known as the
Xerces Native Interface (XNI). XNI is based on the idea of providing a streaming information set. The
XML Infoset specification describes an abstract model of all the information items present in an XML
document, including elements, attributes, characters, and so on. XNI takes the streaming/callback
model used by SAX and expands the callback classes and methods so that as much of the information
set as possible is available to applications that use XNI. As an example, XNI retains the encoding infor-
mation for external entities and passes it along to the application. It also captures the information in the
XML declaration and makes it available. XNI lets you build XML processors as a pipeline of components
connected by the streaming information set.
SAX was designed primarily as a read-only API. XNI provides a read-write model. This allows the
streaming information set to be augmented as it passes from component to component. One important
application is in validating XML schema, which causes the XML infoset to be augmented with informa-
tion—such as datatypes—obtained during validation. The read/write nature of XNI is accomplished by
adding an additional argument to each callback method. This argument is an instance of org.apache
.xerces.xni.Augmentations, which is a data structure like a hash table that allows data to be stored and
retrieved via String keys.
Most developers never look at the XNI interfaces, because they can do everything they want via the
SAX, DOM, or JAXP APIs. But for those looking to exploit the full power of Xerces, digging into the
details of XNI is necessary. We’ll provide a basic overview of the pieces of XNI and how they fit together,
and show an example based on accessing the PSVI.
01 543555 Ch01.qxd 11/5/03 9:40 AM Page 38