KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > sax > Counter


1 /*
2  * Copyright 1999-2002,2004,2005 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package sax;
18
19 import java.io.PrintWriter JavaDoc;
20
21 import org.xml.sax.Attributes JavaDoc;
22 import org.xml.sax.Parser JavaDoc;
23 import org.xml.sax.SAXException JavaDoc;
24 import org.xml.sax.SAXNotRecognizedException JavaDoc;
25 import org.xml.sax.SAXNotSupportedException JavaDoc;
26 import org.xml.sax.SAXParseException JavaDoc;
27 import org.xml.sax.XMLReader JavaDoc;
28 import org.xml.sax.helpers.DefaultHandler JavaDoc;
29 import org.xml.sax.helpers.ParserAdapter JavaDoc;
30 import org.xml.sax.helpers.ParserFactory JavaDoc;
31 import org.xml.sax.helpers.XMLReaderFactory JavaDoc;
32
33 /**
34  * A sample SAX2 counter. This sample program illustrates how to
35  * register a SAX2 ContentHandler and receive the callbacks in
36  * order to print information about the document. The output of
37  * this program shows the time and count of elements, attributes,
38  * ignorable whitespaces, and characters appearing in the document.
39  * <p>
40  * This class is useful as a "poor-man's" performance tester to
41  * compare the speed and accuracy of various SAX parsers. However,
42  * it is important to note that the first parse time of a parser
43  * will include both VM class load time and parser initialization
44  * that would not be present in subsequent parses with the same
45  * file.
46  * <p>
47  * <strong>Note:</strong> The results produced by this program
48  * should never be accepted as true performance measurements.
49  *
50  * @author Andy Clark, IBM
51  *
52  * @version $Id: Counter.java,v 1.14 2005/05/09 00:29:47 mrglavas Exp $
53  */

54 public class Counter
55     extends DefaultHandler JavaDoc {
56
57     //
58
// Constants
59
//
60

61     // feature ids
62

63     /** Namespaces feature id (http://xml.org/sax/features/namespaces). */
64     protected static final String JavaDoc NAMESPACES_FEATURE_ID = "http://xml.org/sax/features/namespaces";
65
66     /** Namespace prefixes feature id (http://xml.org/sax/features/namespace-prefixes). */
67     protected static final String JavaDoc NAMESPACE_PREFIXES_FEATURE_ID = "http://xml.org/sax/features/namespace-prefixes";
68
69     /** Validation feature id (http://xml.org/sax/features/validation). */
70     protected static final String JavaDoc VALIDATION_FEATURE_ID = "http://xml.org/sax/features/validation";
71
72     /** Schema validation feature id (http://apache.org/xml/features/validation/schema). */
73     protected static final String JavaDoc SCHEMA_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/schema";
74
75     /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
76     protected static final String JavaDoc SCHEMA_FULL_CHECKING_FEATURE_ID = "http://apache.org/xml/features/validation/schema-full-checking";
77     
78     /** Validate schema annotations feature id (http://apache.org/xml/features/validate-annotations) */
79     protected static final String JavaDoc VALIDATE_ANNOTATIONS_ID = "http://apache.org/xml/features/validate-annotations";
80
81     /** Dynamic validation feature id (http://apache.org/xml/features/validation/dynamic). */
82     protected static final String JavaDoc DYNAMIC_VALIDATION_FEATURE_ID = "http://apache.org/xml/features/validation/dynamic";
83     
84     /** XInclude feature id (http://apache.org/xml/features/xinclude). */
85     protected static final String JavaDoc XINCLUDE_FEATURE_ID = "http://apache.org/xml/features/xinclude";
86     
87     /** XInclude fixup base URIs feature id (http://apache.org/xml/features/xinclude/fixup-base-uris). */
88     protected static final String JavaDoc XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID = "http://apache.org/xml/features/xinclude/fixup-base-uris";
89     
90     /** XInclude fixup language feature id (http://apache.org/xml/features/xinclude/fixup-language). */
91     protected static final String JavaDoc XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID = "http://apache.org/xml/features/xinclude/fixup-language";
92
93     // default settings
94

95     /** Default parser name. */
96     protected static final String JavaDoc DEFAULT_PARSER_NAME = "org.apache.xerces.parsers.SAXParser";
97
98     /** Default repetition (1). */
99     protected static final int DEFAULT_REPETITION = 1;
100
101     /** Default namespaces support (true). */
102     protected static final boolean DEFAULT_NAMESPACES = true;
103
104     /** Default namespace prefixes (false). */
105     protected static final boolean DEFAULT_NAMESPACE_PREFIXES = false;
106
107     /** Default validation support (false). */
108     protected static final boolean DEFAULT_VALIDATION = false;
109
110     /** Default Schema validation support (false). */
111     protected static final boolean DEFAULT_SCHEMA_VALIDATION = false;
112
113     /** Default Schema full checking support (false). */
114     protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
115     
116     /** Default validate schema annotations (false). */
117     protected static final boolean DEFAULT_VALIDATE_ANNOTATIONS = false;
118
119     /** Default dynamic validation support (false). */
120     protected static final boolean DEFAULT_DYNAMIC_VALIDATION = false;
121     
122     /** Default XInclude processing support (false). */
123     protected static final boolean DEFAULT_XINCLUDE = false;
124     
125     /** Default XInclude fixup base URIs support (true). */
126     protected static final boolean DEFAULT_XINCLUDE_FIXUP_BASE_URIS = true;
127     
128     /** Default XInclude fixup language support (true). */
129     protected static final boolean DEFAULT_XINCLUDE_FIXUP_LANGUAGE = true;
130
131     /** Default memory usage report (false). */
132     protected static final boolean DEFAULT_MEMORY_USAGE = false;
133
134     /** Default "tagginess" report (false). */
135     protected static final boolean DEFAULT_TAGGINESS = false;
136
137     //
138
// Data
139
//
140

141     /** Number of elements. */
142     protected long fElements;
143
144     /** Number of attributes. */
145     protected long fAttributes;
146
147     /** Number of characters. */
148     protected long fCharacters;
149
150     /** Number of ignorable whitespace characters. */
151     protected long fIgnorableWhitespace;
152
153     /** Number of characters of tags. */
154     protected long fTagCharacters;
155
156     /** Number of other content characters for the "tagginess" calculation. */
157     protected long fOtherCharacters;
158
159     //
160
// Constructors
161
//
162

163     /** Default constructor. */
164     public Counter() {
165     } // <init>()
166

167     //
168
// Public methods
169
//
170

171     /** Prints the results. */
172     public void printResults(PrintWriter JavaDoc out, String JavaDoc uri, long time,
173                              long memory, boolean tagginess,
174                              int repetition) {
175
176         // filename.xml: 631 ms (4 elems, 0 attrs, 78 spaces, 0 chars)
177
out.print(uri);
178         out.print(": ");
179         if (repetition == 1) {
180             out.print(time);
181         }
182         else {
183             out.print(time);
184             out.print('/');
185             out.print(repetition);
186             out.print('=');
187             out.print(time/repetition);
188         }
189         out.print(" ms");
190         if (memory != Long.MIN_VALUE) {
191             out.print(", ");
192             out.print(memory);
193             out.print(" bytes");
194         }
195         out.print(" (");
196         out.print(fElements);
197         out.print(" elems, ");
198         out.print(fAttributes);
199         out.print(" attrs, ");
200         out.print(fIgnorableWhitespace);
201         out.print(" spaces, ");
202         out.print(fCharacters);
203         out.print(" chars)");
204         if (tagginess) {
205             out.print(' ');
206             long totalCharacters = fTagCharacters + fOtherCharacters
207                                  + fCharacters + fIgnorableWhitespace;
208             long tagValue = fTagCharacters * 100 / totalCharacters;
209             out.print(tagValue);
210             out.print("% tagginess");
211         }
212         out.println();
213         out.flush();
214
215     } // printResults(PrintWriter,String,long)
216

217     //
218
// ContentHandler methods
219
//
220

221     /** Start document. */
222     public void startDocument() throws SAXException JavaDoc {
223
224         fElements = 0;
225         fAttributes = 0;
226         fCharacters = 0;
227         fIgnorableWhitespace = 0;
228         fTagCharacters = 0;
229
230     } // startDocument()
231

232     /** Start element. */
233     public void startElement(String JavaDoc uri, String JavaDoc local, String JavaDoc raw,
234                              Attributes JavaDoc attrs) throws SAXException JavaDoc {
235
236         fElements++;
237         fTagCharacters++; // open angle bracket
238
fTagCharacters += raw.length();
239         if (attrs != null) {
240             int attrCount = attrs.getLength();
241             fAttributes += attrCount;
242             for (int i = 0; i < attrCount; i++) {
243                 fTagCharacters++; // space
244
fTagCharacters += attrs.getQName(i).length();
245                 fTagCharacters++; // '='
246
fTagCharacters++; // open quote
247
fOtherCharacters += attrs.getValue(i).length();
248                 fTagCharacters++; // close quote
249
}
250         }
251         fTagCharacters++; // close angle bracket
252

253     } // startElement(String,String,StringAttributes)
254

255     /** Characters. */
256     public void characters(char ch[], int start, int length)
257         throws SAXException JavaDoc {
258
259         fCharacters += length;
260
261     } // characters(char[],int,int);
262

263     /** Ignorable whitespace. */
264     public void ignorableWhitespace(char ch[], int start, int length)
265         throws SAXException JavaDoc {
266
267         fIgnorableWhitespace += length;
268
269     } // ignorableWhitespace(char[],int,int);
270

271     /** Processing instruction. */
272     public void processingInstruction(String JavaDoc target, String JavaDoc data)
273         throws SAXException JavaDoc {
274         fTagCharacters += 2; // "<?"
275
fTagCharacters += target.length();
276         if (data != null && data.length() > 0) {
277             fTagCharacters++; // space
278
fOtherCharacters += data.length();
279         }
280         fTagCharacters += 2; // "?>"
281
} // processingInstruction(String,String)
282

283     //
284
// ErrorHandler methods
285
//
286

287     /** Warning. */
288     public void warning(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
289         printError("Warning", ex);
290     } // warning(SAXParseException)
291

292     /** Error. */
293     public void error(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
294         printError("Error", ex);
295     } // error(SAXParseException)
296

297     /** Fatal error. */
298     public void fatalError(SAXParseException JavaDoc ex) throws SAXException JavaDoc {
299         printError("Fatal Error", ex);
300         //throw ex;
301
} // fatalError(SAXParseException)
302

303     //
304
// Protected methods
305
//
306

307     /** Prints the error message. */
308     protected void printError(String JavaDoc type, SAXParseException JavaDoc ex) {
309
310         System.err.print("[");
311         System.err.print(type);
312         System.err.print("] ");
313         if (ex== null) {
314             System.out.println("!!!");
315         }
316         String JavaDoc systemId = ex.getSystemId();
317         if (systemId != null) {
318             int index = systemId.lastIndexOf('/');
319             if (index != -1)
320                 systemId = systemId.substring(index + 1);
321             System.err.print(systemId);
322         }
323         System.err.print(':');
324         System.err.print(ex.getLineNumber());
325         System.err.print(':');
326         System.err.print(ex.getColumnNumber());
327         System.err.print(": ");
328         System.err.print(ex.getMessage());
329         System.err.println();
330         System.err.flush();
331
332     } // printError(String,SAXParseException)
333

334     //
335
// MAIN
336
//
337

338     /** Main program entry point. */
339     public static void main(String JavaDoc argv[]) {
340
341         // is there anything to do?
342
if (argv.length == 0) {
343             printUsage();
344             System.exit(1);
345         }
346
347         // variables
348
Counter counter = new Counter();
349         PrintWriter JavaDoc out = new PrintWriter JavaDoc(System.out);
350         XMLReader JavaDoc parser = null;
351         int repetition = DEFAULT_REPETITION;
352         boolean namespaces = DEFAULT_NAMESPACES;
353         boolean namespacePrefixes = DEFAULT_NAMESPACE_PREFIXES;
354         boolean validation = DEFAULT_VALIDATION;
355         boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
356         boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
357         boolean validateAnnotations = DEFAULT_VALIDATE_ANNOTATIONS;
358         boolean dynamicValidation = DEFAULT_DYNAMIC_VALIDATION;
359         boolean xincludeProcessing = DEFAULT_XINCLUDE;
360         boolean xincludeFixupBaseURIs = DEFAULT_XINCLUDE_FIXUP_BASE_URIS;
361         boolean xincludeFixupLanguage = DEFAULT_XINCLUDE_FIXUP_LANGUAGE;
362         boolean memoryUsage = DEFAULT_MEMORY_USAGE;
363         boolean tagginess = DEFAULT_TAGGINESS;
364
365         // process arguments
366
for (int i = 0; i < argv.length; i++) {
367             String JavaDoc arg = argv[i];
368             if (arg.startsWith("-")) {
369                 String JavaDoc option = arg.substring(1);
370                 if (option.equals("p")) {
371                     // get parser name
372
if (++i == argv.length) {
373                         System.err.println("error: Missing argument to -p option.");
374                         continue;
375                     }
376                     String JavaDoc parserName = argv[i];
377
378                     // create parser
379
try {
380                         parser = XMLReaderFactory.createXMLReader(parserName);
381                     }
382                     catch (Exception JavaDoc e) {
383                         try {
384                             Parser JavaDoc sax1Parser = ParserFactory.makeParser(parserName);
385                             parser = new ParserAdapter JavaDoc(sax1Parser);
386                             System.err.println("warning: Features and properties not supported on SAX1 parsers.");
387                         }
388                         catch (Exception JavaDoc ex) {
389                             parser = null;
390                             System.err.println("error: Unable to instantiate parser ("+parserName+")");
391                         }
392                     }
393                     continue;
394                 }
395                 if (option.equals("x")) {
396                     if (++i == argv.length) {
397                         System.err.println("error: Missing argument to -x option.");
398                         continue;
399                     }
400                     String JavaDoc number = argv[i];
401                     try {
402                         int value = Integer.parseInt(number);
403                         if (value < 1) {
404                             System.err.println("error: Repetition must be at least 1.");
405                             continue;
406                         }
407                         repetition = value;
408                     }
409                     catch (NumberFormatException JavaDoc e) {
410                         System.err.println("error: invalid number ("+number+").");
411                     }
412                     continue;
413                 }
414                 if (option.equalsIgnoreCase("n")) {
415                     namespaces = option.equals("n");
416                     continue;
417                 }
418                 if (option.equalsIgnoreCase("np")) {
419                     namespacePrefixes = option.equals("np");
420                     continue;
421                 }
422                 if (option.equalsIgnoreCase("v")) {
423                     validation = option.equals("v");
424                     continue;
425                 }
426                 if (option.equalsIgnoreCase("s")) {
427                     schemaValidation = option.equals("s");
428                     continue;
429                 }
430                 if (option.equalsIgnoreCase("f")) {
431                     schemaFullChecking = option.equals("f");
432                     continue;
433                 }
434                 if (option.equalsIgnoreCase("va")) {
435                     validateAnnotations = option.equals("va");
436                     continue;
437                 }
438                 if (option.equalsIgnoreCase("dv")) {
439                     dynamicValidation = option.equals("dv");
440                     continue;
441                 }
442                 if (option.equalsIgnoreCase("xi")) {
443                     xincludeProcessing = option.equals("xi");
444                     continue;
445                 }
446                 if (option.equalsIgnoreCase("xb")) {
447                     xincludeFixupBaseURIs = option.equals("xb");
448                     continue;
449                 }
450                 if (option.equalsIgnoreCase("xl")) {
451                     xincludeFixupLanguage = option.equals("xl");
452                     continue;
453                 }
454                 if (option.equalsIgnoreCase("m")) {
455                     memoryUsage = option.equals("m");
456                     continue;
457                 }
458                 if (option.equalsIgnoreCase("t")) {
459                     tagginess = option.equals("t");
460                     continue;
461                 }
462                 if (option.equals("-rem")) {
463                     if (++i == argv.length) {
464                         System.err.println("error: Missing argument to -# option.");
465                         continue;
466                     }
467                     System.out.print("# ");
468                     System.out.println(argv[i]);
469                     continue;
470                 }
471                 if (option.equals("h")) {
472                     printUsage();
473                     continue;
474                 }
475                 System.err.println("error: unknown option ("+option+").");
476                 continue;
477             }
478
479             // use default parser?
480
if (parser == null) {
481
482                 // create parser
483
try {
484                     parser = XMLReaderFactory.createXMLReader(DEFAULT_PARSER_NAME);
485                 }
486                 catch (Exception JavaDoc e) {
487                     System.err.println("error: Unable to instantiate parser ("+DEFAULT_PARSER_NAME+")");
488                     continue;
489                 }
490             }
491
492             // set parser features
493
try {
494                 parser.setFeature(NAMESPACES_FEATURE_ID, namespaces);
495             }
496             catch (SAXException JavaDoc e) {
497                 System.err.println("warning: Parser does not support feature ("+NAMESPACES_FEATURE_ID+")");
498             }
499             try {
500                 parser.setFeature(NAMESPACE_PREFIXES_FEATURE_ID, namespacePrefixes);
501             }
502             catch (SAXException JavaDoc e) {
503                 System.err.println("warning: Parser does not support feature ("+NAMESPACE_PREFIXES_FEATURE_ID+")");
504             }
505             try {
506                 parser.setFeature(VALIDATION_FEATURE_ID, validation);
507             }
508             catch (SAXException JavaDoc e) {
509                 System.err.println("warning: Parser does not support feature ("+VALIDATION_FEATURE_ID+")");
510             }
511             try {
512                 parser.setFeature(SCHEMA_VALIDATION_FEATURE_ID, schemaValidation);
513             }
514             catch (SAXNotRecognizedException JavaDoc e) {
515                 System.err.println("warning: Parser does not recognize feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
516
517             }
518             catch (SAXNotSupportedException JavaDoc e) {
519                 System.err.println("warning: Parser does not support feature ("+SCHEMA_VALIDATION_FEATURE_ID+")");
520             }
521             try {
522                 parser.setFeature(SCHEMA_FULL_CHECKING_FEATURE_ID, schemaFullChecking);
523             }
524             catch (SAXNotRecognizedException JavaDoc e) {
525                 System.err.println("warning: Parser does not recognize feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
526
527             }
528             catch (SAXNotSupportedException JavaDoc e) {
529                 System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
530             }
531             try {
532                 parser.setFeature(VALIDATE_ANNOTATIONS_ID, validateAnnotations);
533             }
534             catch (SAXNotRecognizedException JavaDoc e) {
535                 System.err.println("warning: Parser does not recognize feature ("+VALIDATE_ANNOTATIONS_ID+")");
536
537             }
538             catch (SAXNotSupportedException JavaDoc e) {
539                 System.err.println("warning: Parser does not support feature ("+VALIDATE_ANNOTATIONS_ID+")");
540             }
541             try {
542                 parser.setFeature(DYNAMIC_VALIDATION_FEATURE_ID, dynamicValidation);
543             }
544             catch (SAXNotRecognizedException JavaDoc e) {
545                 System.err.println("warning: Parser does not recognize feature ("+DYNAMIC_VALIDATION_FEATURE_ID+")");
546
547             }
548             catch (SAXNotSupportedException JavaDoc e) {
549                 System.err.println("warning: Parser does not support feature ("+DYNAMIC_VALIDATION_FEATURE_ID+")");
550             }
551             try {
552                 parser.setFeature(XINCLUDE_FEATURE_ID, xincludeProcessing);
553             }
554             catch (SAXNotRecognizedException JavaDoc e) {
555                 System.err.println("warning: Parser does not recognize feature ("+XINCLUDE_FEATURE_ID+")");
556
557             }
558             catch (SAXNotSupportedException JavaDoc e) {
559                 System.err.println("warning: Parser does not support feature ("+XINCLUDE_FEATURE_ID+")");
560             }
561             try {
562                 parser.setFeature(XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID, xincludeFixupBaseURIs);
563             }
564             catch (SAXNotRecognizedException JavaDoc e) {
565                 System.err.println("warning: Parser does not recognize feature ("+XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID+")");
566
567             }
568             catch (SAXNotSupportedException JavaDoc e) {
569                 System.err.println("warning: Parser does not support feature ("+XINCLUDE_FIXUP_BASE_URIS_FEATURE_ID+")");
570             }
571             try {
572                 parser.setFeature(XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID, xincludeFixupLanguage);
573             }
574             catch (SAXNotRecognizedException JavaDoc e) {
575                 System.err.println("warning: Parser does not recognize feature ("+XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID+")");
576
577             }
578             catch (SAXNotSupportedException JavaDoc e) {
579                 System.err.println("warning: Parser does not support feature ("+XINCLUDE_FIXUP_LANGUAGE_FEATURE_ID+")");
580             }
581
582             // parse file
583
parser.setContentHandler(counter);
584             parser.setErrorHandler(counter);
585             try {
586                 long timeBefore = System.currentTimeMillis();
587                 long memoryBefore = Runtime.getRuntime().freeMemory();
588                 for (int j = 0; j < repetition; j++) {
589                     parser.parse(arg);
590                 }
591                 long memoryAfter = Runtime.getRuntime().freeMemory();
592                 long timeAfter = System.currentTimeMillis();
593
594                 long time = timeAfter - timeBefore;
595                 long memory = memoryUsage
596                             ? memoryBefore - memoryAfter : Long.MIN_VALUE;
597                 counter.printResults(out, arg, time, memory, tagginess,
598                                      repetition);
599             }
600             catch (SAXParseException JavaDoc e) {
601                 // ignore
602
}
603             catch (Exception JavaDoc e) {
604                 System.err.println("error: Parse error occurred - "+e.getMessage());
605                 Exception JavaDoc se = e;
606                 if (e instanceof SAXException JavaDoc) {
607                     se = ((SAXException JavaDoc)e).getException();
608                 }
609                 if (se != null)
610                   se.printStackTrace(System.err);
611                 else
612                   e.printStackTrace(System.err);
613
614             }
615         }
616
617     } // main(String[])
618

619     //
620
// Private static methods
621
//
622

623     /** Prints the usage. */
624     private static void printUsage() {
625
626         System.err.println("usage: java sax.Counter (options) uri ...");
627         System.err.println();
628
629         System.err.println("options:");
630         System.err.println(" -p name Select parser by name.");
631         System.err.println(" -x number Select number of repetitions.");
632         System.err.println(" -n | -N Turn on/off namespace processing.");
633         System.err.println(" -np | -NP Turn on/off namespace prefixes.");
634         System.err.println(" NOTE: Requires use of -n.");
635         System.err.println(" -v | -V Turn on/off validation.");
636         System.err.println(" -s | -S Turn on/off Schema validation support.");
637         System.err.println(" NOTE: Not supported by all parsers.");
638         System.err.println(" -f | -F Turn on/off Schema full checking.");
639         System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
640         System.err.println(" -va | -VA Turn on/off validation of schema annotations.");
641         System.err.println(" NOTE: Requires use of -s and not supported by all parsers.");
642         System.err.println(" -dv | -DV Turn on/off dynamic validation.");
643         System.err.println(" NOTE: Not supported by all parsers.");
644         System.err.println(" -xi | -XI Turn on/off XInclude processing.");
645         System.err.println(" NOTE: Not supported by all parsers.");
646         System.err.println(" -xb | -XB Turn on/off base URI fixup during XInclude processing.");
647         System.err.println(" NOTE: Requires use of -xi and not supported by all parsers.");
648         System.err.println(" -xl | -XL Turn on/off language fixup during XInclude processing.");
649         System.err.println(" NOTE: Requires use of -xi and not supported by all parsers.");
650         System.err.println(" -m | -M Turn on/off memory usage report");
651         System.err.println(" -t | -T Turn on/off \"tagginess\" report.");
652         System.err.println(" --rem text Output user defined comment before next parse.");
653         System.err.println(" -h This help screen.");
654
655         System.err.println();
656         System.err.println("defaults:");
657         System.err.println(" Parser: "+DEFAULT_PARSER_NAME);
658         System.err.println(" Repetition: "+DEFAULT_REPETITION);
659         System.err.print(" Namespaces: ");
660         System.err.println(DEFAULT_NAMESPACES ? "on" : "off");
661         System.err.print(" Prefixes: ");
662         System.err.println(DEFAULT_NAMESPACE_PREFIXES ? "on" : "off");
663         System.err.print(" Validation: ");
664         System.err.println(DEFAULT_VALIDATION ? "on" : "off");
665         System.err.print(" Schema: ");
666         System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
667         System.err.print(" Schema full checking: ");
668         System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
669         System.err.print(" Dynamic: ");
670         System.err.println(DEFAULT_DYNAMIC_VALIDATION ? "on" : "off");
671         System.err.print(" XInclude: ");
672         System.err.println(DEFAULT_XINCLUDE ? "on" : "off");
673         System.err.print(" XInclude base URI fixup: ");
674         System.err.println(DEFAULT_XINCLUDE_FIXUP_BASE_URIS ? "on" : "off");
675         System.err.print(" XInclude language fixup: ");
676         System.err.println(DEFAULT_XINCLUDE_FIXUP_LANGUAGE ? "on" : "off");
677         System.err.print(" Memory: ");
678         System.err.println(DEFAULT_MEMORY_USAGE ? "on" : "off");
679         System.err.print(" Tagginess: ");
680         System.err.println(DEFAULT_TAGGINESS ? "on" : "off");
681
682         System.err.println();
683         System.err.println("notes:");
684         System.err.println(" The speed and memory results from this program should NOT be used as the");
685         System.err.println(" basis of parser performance comparison! Real analytical methods should be");
686         System.err.println(" used. For better results, perform multiple document parses within the same");
687         System.err.println(" virtual machine to remove class loading from parse time and memory usage.");
688         System.err.println();
689         System.err.println(" The \"tagginess\" measurement gives a rough estimate of the percentage of");
690         System.err.println(" markup versus content in the XML document. The percent tagginess of a ");
691         System.err.println(" document is equal to the minimum amount of tag characters required for ");
692         System.err.println(" elements, attributes, and processing instructions divided by the total");
693         System.err.println(" amount of characters (characters, ignorable whitespace, and tag characters)");
694         System.err.println(" in the document.");
695         System.err.println();
696         System.err.println(" Not all features are supported by different parsers.");
697
698     } // printUsage()
699

700 } // class Counter
701
Popular Tags