| Questions |
| Augmentations Overriding Default Parser Configuration Xerces Parser Configurations
| Answers |
| What are all these strange "Augmentations" parameters I see in so many methods? |
| They're intended to provide a way to augment the basic XML infoset available from the non-Augmentation parameters in the callbacks. They can be used by a component to add arbitrary information to the streaming infoset, which can then be interpreted by some later component. For instance, a component can be written to transmit the post schema validation infoset through Augmentations callbacks. This can then be translated into an XML representation. This is exactly what is done in the PSVI Writer and PSVI Configuration samples--see XNI sample documentation for details.
| How do I change the default parser configuration? |
| It is possible to override the default parser configuration used by the Xerces2 parsers without writing any code or changing the existing parser classes. Moreover, the DOM and SAX parsers created using the JAXP interfaces will use the specified parser configuration transparently and without need to call additional methods to set the parser configuration. The DOM and SAX parsers decide which parser configuration to use in the following order: First, the `org.apache.xerces.xni.parser.XMLParserConfiguration` system property is queried for the class name of the parser configuration. Next, if a file called `xerces.properties` exists in the lib subdirectory of the JRE installation and the `org.apache.xerces.xni.parser.XMLParserConfiguration` property is defined it, then its value will be read from the file. Next, the `org.apache.xerces.xni.parser.XMLParserConfiguration` file is requested from the `META-INF/services/` directory. This file contains the class name of the parser configuration. Finally, the `org.apache.xerces.parsers.XIncludeAwareParserConfiguration` is used as the default parser configuration.
| In all cases, the parser configuration class must have a public, no argument constructor so that it can be instantiated dynamically.
When using Java 2, it is not necessary to rebuild the Xerces jar files in order to override the default parser configuration using the first method. As long as a JAR file containing the appropriate file exists in the `META-INF/services/` directory appears before the Xerces JAR files, the parser will use the new parser configuration. The first method can always be used on the command line for the JVM by using the `-D` option. For example, to override the default parser configuration using a custom configuration named `MyConfig`, use the following command line:
    java -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=MyConfig application_class
| In the Xerces distribution, what are the available parser configurations? |
| The default parser configuration is `org.apache.xerces.parsers.XIncludeAwareParserConfiguration`. It and the other available parser configurations are described in the table below. All of them are located in the `org.apache.xerces.parsers` package.
Configuration | Description
DTDConfiguration | A DTD-only configuration. Contains components appropriate to DTD-centric validation.
IntegratedParserConfiguration | Extends StandardParserConfiguration by including a scanner that integrates both scanning of the document and binding namespaces.
NonValidatingConfiguration | A non-validating configuration. It does not provide a conformant non-validating XML processor because it does not process the declarations in an internal subset besides checking their well-formedness.
SecurityConfiguration | Extends the default configuration allowing Xerces to behave in a more security conscious manner by installing a SecurityManager.
SoftReferenceSymbolTableConfiguration | Extends the default configuration allowing Xerces to handle usage scenarios where the names in the XML documents being parsed are mostly unique by installing a memory sensitive SymbolTable. The internalized strings stored in this SymbolTable are softly reachable and may be cleared by the garbage collector in response to memory demand.
StandardParserConfiguration | Extends DTDConfiguration by adding support for XML schema validation.
XIncludeAwareParserConfiguration | Extends XML11Configuration by providing support for XInclude. See the XInclude FAQ.
XML11Configuration | Like IntegratedParserConfiguration except that it supports XML 1.1 in addition to XML 1.0.
XML11DTDConfiguration | Like DTDConfiguration except that it supports XML 1.1 in addition to XML 1.0.
XML11NonValidatingConfiguration | Like NonValidatingConfiguration except that it supports XML 1.1 in addition to XML 1.0.
XMLGrammarCachingConfiguration | Extends the default configuration by providing a generic way of using Xerces' grammar caching facilities.

Copyright © 1999-2007 The Apache Software Foundation. All Rights Reserved.