Chapter 4 XML Processing
187
When you use JAXP, you can later change the underlying parser implementation
without having to change application code.
4.5.3.1
Tune Underlying Parser and Style Sheet Engine Implementations
The JAXP API defines methods to set and get features and properties for configur 
ing the underlying parser and style sheet engine implementations. A particular
parser, document builder, or transformer implementation may define specific fea 
tures and properties to switch on or off specific behaviors dedicated to performance
improvement. These are separate from such standard properties and features, such
as the 
http://xml.org/sax/features/validation
 feature used to turn validation
on or off.
For example, Xerces defines a deferred expansion feature called
http://apache.org/xml/features/dom/defer node expansion
, which enables
or disables a lazy DOM mode. In lazy mode (enabled by default), the DOM tree
nodes are lazily evaluated, their creation is deferred: They are created only when
they are accessed. As a result, DOM tree construction from an XML document
returns faster since only accessed nodes are expanded. This feature is particularly
useful when processing only parts of the DOM tree. Grammar caching, another
feature available in Xerces, improves performance by avoiding repeated parsing
of the same XML schemas. This is especially useful when an application pro 
cesses a limited number of schemas, which is typically the case with Web ser 
vices.
Use care when setting specific features and properties to preserve the inter 
changeability of the underlying implementation. When the underlying implemen 
tation encounters a feature or a property that it does not support or recognize, the
SAXParserFactory
, the 
XMLReader
, or the 
DocumentBuilderFactory
 may throw
these exceptions: a 
SAXNotRecognizedException
, a 
SAXNotSupportedException
,
or an 
IllegalArgumentException
. Avoid grouping unrelated features and proper 
ties, especially standard versus specific ones, in a single 
try/catch
 block. Instead,
handle exceptions independently so that optional specific features or properties do
not prevent switching to a different implementation. You may design your appli 
cation in such a way that features and properties specific to the underlying imple 
mentations may also be defined externally to the application, such as in a
configuration file.






New Page 1








Home : About Us : Network : Services : Support : FAQ : Control Panel : Order Online : Sitemap : Contact : Terms Of Service

java web hosting

 

 

 Our partners: | PHP: Hypertext Preprocessor | Best Web Hosting | Java Web Hosting | Inexpensive Web Hosting |

Jsp Web Hosting | Cheapest Web Hosting | Jsp Hosting | Cheap Hosting

 

Virtualwebstudio. Business web hosting division of Web Design Plus. All rights reserved