Datasheet
Error Reporter
The parser configuration needs a single mechanism that all components can use to report errors. The
Xerces2 error reporter provides a single point for all components to report errors. It also provides some
support for localizing the error messages and calling the XNI XMLErrorHandler callback. Localization
works as follows. Each component is given a domain designated by a URI. The component then imple-
ments the org.apache.xerces.util.MessageFormatter interface to generate and localize its own error mes-
sages. This component is used by almost all the other Xerces2 components, so you need to have one of
them in your configuration if you use any of them. The error reporter is implemented by the class
org.apache.xerces.impl.XMLErrorReporter and uses the URI http://apache.org/xml/properties
/internal/error-reporter as its property ID.
Entity Manager
Xerces2 provides an entity manager that handles the starting and stopping of entities within an XML
document. This gives its clients (primarily the document scanner and DTD scanner) the illusion that
there is a single entity, not multiple entities. The entity manager is implemented by the class
org.apache.xerces.impl.EntityManager and uses the URI http://apache.org/xml/properties
/internal/entity-manager as its property id. To use it, you also need the error reporter and the symbol
table.
Symbol Table
XML parsers look at a lot of text when processing documents. Much of that text (element and attribute
names, namespaces prefixes, and so on) is repeated in XML documents. Xerces2 tries to take advantage
of that fact by providing a custom symbol table for strings in order to improve performance. The symbol
table always returns the same java.lang.String reference for a given string value. This means components
can compare strings by comparing these references, not by comparing the string values. So, not only
does the symbol table save space, it helps replace expensive calls to String#equals() with calls to ==. This
component is used by all the rest of the Xerces2 components, so your configuration needs one of them if
you use any Xerces2 components. The symbol table is implemented by the class org.apache.xerces.
util.SymbolTable and uses the URI http://apache.org/xml/properties/internal/symbol-table as its
property ID.
Using the Samples
The Xerces distribution includes a number of sample programs, some of which can be very useful when
you’re developing programs using Xerces—especially when you’ve embedded Xerces into your applica-
tion. Suppose you’re trying to debug an application and the problem appears to be inside Xerces itself.
You may be seeing exceptions thrown or getting answers you think are incorrect. One debugging
method that can save a lot of time is to capture the XML that’s being input to Xerces, save it a file, and
drag out one of the samples to help you see what’s going on.
Before you use any of the samples, you need to get to a command-line prompt on your operating sys-
tem. Make sure that xml-apis.jar, xercesImpl.jar, and xercesSamples.jar are all on your classpath.
43
Xerces
01 543555 Ch01.qxd 11/5/03 9:40 AM Page 43