sax\Counter.java - Apache Xerves SAX Sample

Q

What is the sax\Counter.java provided in the Apache Xerces package? I have Apache Xerces 2.11.0 installed.

✍: FYIcenter

A

sax\Counter.java provided in the Apache Xerces package illustrates how to register a SAX2 ContentHandler and receive the callbacks in order to print information about the document. The output of this program shows the time and count of elements, attributes, ignorable whitespaces, and characters appearing in the document.

Here is how to run sax\Counter.java, if you have Apache Xerces 2.11.0 installed:

>\fyicenter\jdk-1.8.0\bin\java 
   -cp \fyicenter\xerces-2_11_0\xercesSamples.jar sax.Counter
   
usage: java sax.Counter (options) uri ...

options:
  -p name     Select parser 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 parsers.
  -f  | -F    Turn on/off Schema full checking.
              NOTE: Requires use of -s and not supported by all parsers.
  -hs | -HS   Turn on/off honouring of all schema locations.
              NOTE: Requires use of -s and not supported by all parsers.
  -va | -VA   Turn on/off validation of schema annotations.
              NOTE: Requires use of -s and not supported by all parsers.
  -dv | -DV   Turn on/off dynamic validation.
              NOTE: Not supported by all parsers.
  -xi | -XI   Turn on/off XInclude processing.
              NOTE: Not supported by all parsers.
  -xb | -XB   Turn on/off base URI fixup during XInclude processing.
              NOTE: Requires use of -xi and not supported by all parsers.
  -xl | -XL   Turn on/off language fixup during XInclude processing.
              NOTE: Requires use of -xi 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          This help screen.

defaults:
  Parser:     org.apache.xerces.parsers.SAXParser
  Repetition: 1
  Namespaces: on
  Prefixes:   off
  Validation: off
  Schema:     off
  Schema full checking:            off
  Honour all schema locations:     off
  Validate annotations:            off
  Dynamic:    off
  XInclude:   off
  XInclude base URI fixup:  on
  XInclude language fixup:  on
  Memory:     off
  Tagginess:  off

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 parsers.

 

Using Apache Xerces SAX Sample Programs

⇒⇒FAQ for Apache Xerces XML Parser

2017-10-23, 976👍, 0💬