http://xml.apache.org/http://www.apache.org/http://www.w3.org/

Home

Readme
Installation
Download
CVS Repository

Samples
API JavaDoc
FAQs

Features
Properties

XNI Manual
XML Schema
DOM
Limitations

Release Info
Report a Bug

Overview
 

The Xerces Native Interface (XNI) is an internal API that is independent of other XML APIs and is used to implement the Xerces family of parsers. XNI allows a wide variety of parsers to be written in an easy and modular fashion. The XNI samples included with Xerces are simple examples of how to program using the XNI API. However, for information on how to take full advantage of this powerful framework, refer to the XNI Manual.

Basic XNI samples:

Parser configuration samples:

Most of the XNI samples have a command line option that allows the user to specify a different XNI parser configuration to use. In order to supply another parser configuration besides the default Xerces StandardParserConfiguration, the configuration must implement the org.apache.xerces.xni.parser.XMLParserConfiguration interface.


Sample xni.Counter
 

A sample XNI counter. The output of this program shows the time and count of elements, attributes, ignorable whitespaces, and characters appearing in the document.

This class is useful as a "poor-man's" performance tester to compare the speed and accuracy of various parser configurations. However, it is important to note that the first parse time of a parser will include both VM class load time and parser initialization that would not be present in subsequent parses with the same file.

Note: The results produced by this program should never be accepted as true performance measurements.
usage
 
java xni.Counter (options) uri ...

options
 
Option  Description 
-p name  Select parser configuration by name. 
-x number  Select number of repetitions. 
-n | -N  Turn on/off namespace processing. 
-np | -NP  Turn on/off namespace prefixes.
NOTE: Requires use of -n.  
-v | -V  Turn on/off validation. 
-s | -S  Turn on/off Schema validation support.
NOTE: Not supported by all parser configurations.  
-f | -F  Turn on/off Schema full checking.
NOTE: Requires use of -s and not supported by all parsers.  
-m | -M  Turn on/off memory usage report. 
-t | -T  Turn on/off \"tagginess\" report. 
--rem text  Output user defined comment before next parse. 
-h  Display help screen. 

notes
 

The speed and memory results from this program should NOT be used as the basis of parser performance comparison! Real analytical methods should be used. For better results, perform multiple document parses within the same virtual machine to remove class loading from parse time and memory usage.

The "tagginess" measurement gives a rough estimate of the percentage of markup versus content in the XML document. The percent tagginess of a document is equal to the minimum amount of tag characters required for elements, attributes, and processing instructions divided by the total amount of characters (characters, ignorable whitespace, and tag characters) in the document.

Not all features are supported by different parser configurations.



Sample xni.DocumentTracer
 

Provides a complete trace of XNI document and DTD events for files parsed.

usage
 
java xni.DocumentTracer (options) uri ...

options
 
Option  Description 
-p name  Specify parser configuration by name. 
-n | -N  Turn on/off namespace processing. 
-v | -V  Turn on/off validation. 
-s | -S  Turn on/off Schema validation support.
NOTE: Not supported by all parser configurations.  
-c | -C  Turn on/off character notifications"); 
-h  Display help screen. 


Sample xni.Writer
 

A sample XNI writer. This sample program illustrates how to take receive XMLDocumentHandler callbacks in order to print a document that is parsed.

usage
 
java xni.Writer (options) uri ...

options
 
Option  Description 
-p name  Select parser configuration by name. 
-n | -N  Turn on/off namespace processing. 
-v | -V  Turn on/off validation. 
-s | -S  Turn on/off Schema validation support.
NOTE: Not supported by all parser configurations.  
-h  Display help screen. 


Sample xni.PSVIWriter
 

This is an example of a component that intercepts document handler events and gathers PSVI information. The PSVI output is written as XML.

This class can NOT be run as a standalone program. It is only an example of how to write a component. See xni.parser.PSVIParser.


Sample xni.PassThroughFilter
 

This sample demonstrates how to implement a simple pass-through filter for the document "streaming" information set using XNI. This filter could be used in a pipeline of XNI parser components that communicate document events.

This class can NOT be run as a standalone program. It is only an example of how to write a document handler.


Sample xni.UpperCaseFilter
 

This sample demonstrates how to create a filter for the document "streaming" information set that turns element names into upper case.

This class can NOT be run as a standalone program. It is only an example of how to write a document handler.


Sample xni.parser.NonValidatingParserConfiguration
 

Non-validating parser configuration.

This class can NOT be run as a standalone program. It is only an example of how to write a parser configuration using XNI. You can use this parser configuration by specifying the fully qualified class name to all of the XNI samples that accept a parser configuration using the -p option. For example:

java xni.Counter -p xni.parser.NonValidatingParserConfiguration document.xml

Sample xni.parser.AbstractConfiguration
 

This abstract parser configuration simply helps manage components, features and properties, and other tasks common to all parser configurations. In order to subclass this configuration and use it effectively, the subclass is required to do the following:

  • Add all configurable components using the addComponent method,
  • Implement the parse method, and
  • Call the resetComponents before parsing.

This class can NOT be run as a standalone program. It is only an example of how to write a parser configuration using XNI.


Sample xni.parser.CSVConfiguration
 

This example is a very simple parser configuration that can parse files with comma-separated values (CSV) to generate XML events. For example, the following CSV document:

Andy Clark,16 Jan 1973,Cincinnati

produces the following XML "document" as represented by the XNI streaming document information:

<?xml version='1.0' encoding='UTF-8' standalone='true'?>
<!DOCTYPE csv [
<!ELEMENT csv (row)*>
<!ELEMENT row (col)*>
<!ELEMENT col (#PCDATA)>
]>
<csv>
 <row>
  <col>Andy Clark</col>
  <col>16 Jan 1973</col>
  <col>Cincinnati</col>
 </row>
</csv>

This class can NOT be run as a standalone program. It is only an example of how to write a parser configuration using XNI. You can use this parser configuration by specifying the fully qualified class name to all of the XNI samples that accept a parser configuration using the -p option. For example:

java xni.Counter -p xni.parser.CSVConfiguration document.xml

Samples xni.parser.CSVParser
 

This parser class implements a SAX parser that can parse simple comma-separated value (CSV) files.

This class can NOT be run as a standalone program. It is only an example of how to write a parser using XNI. You can use this parser by specifying the fully qualified class name to all of the SAX samples that accept a parser using the -p option. For example:

java sax.Counter -p xni.parser.CSVParser document.xml

Sample xni.parser.PSVIConfiguration
 

This example is a parser configuration that can output post schema validation infoset. The configuration infludes: DTD validator, Namespace binder, XML Schema validators and PSVIWriter component.

This class can NOT be run as a standalone program. It is only an example of how to write a parser configuration using XNI. You can use this parser configuration by specifying the fully qualified class name to all of the XNI samples that accept a parser configuration using the -p option:

java xni.Counter -v -s -p xni.parser.PSVIConfiguration personal-schema.xml
Note:Validation and schema validation features must be set to true to receive the correct PSVI output.

Samples xni.parser.PSVIParser
 

This parser class implements a SAX parser that outputs post schema validation infoset as XML.

This class can NOT be run as a standalone program. It is only an example of how to write a parser using XNI. You can use this parser by specifying the fully qualified class name to all of the SAX samples that accept a parser using the -p option. For example:

java sax.Counter -v -s -p xni.parser.PSVIParser personal-schema.xml
Note:Validation and schema validation features must be set to true to receive the correct PSVI output.


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