~ubuntu-branches/ubuntu/karmic/libxerces2-java/karmic

« back to all changes in this revision

Viewing changes to samples/xni/Counter.java

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2006-12-04 17:37:55 UTC
  • mfrom: (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20061204173755-hb6ybrrrk097zhx7
Tags: 2.8.1-1ubuntu1
* Merge with Debian unstable; remaining changes:
  - Build -gcj package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * The Apache Software License, Version 1.1
3
 
 *
4
 
 *
5
 
 * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
6
 
 * reserved.
7
 
 *
8
 
 * Redistribution and use in source and binary forms, with or without
9
 
 * modification, are permitted provided that the following conditions
10
 
 * are met:
11
 
 *
12
 
 * 1. Redistributions of source code must retain the above copyright
13
 
 *    notice, this list of conditions and the following disclaimer.
14
 
 *
15
 
 * 2. Redistributions in binary form must reproduce the above copyright
16
 
 *    notice, this list of conditions and the following disclaimer in
17
 
 *    the documentation and/or other materials provided with the
18
 
 *    distribution.
19
 
 *
20
 
 * 3. The end-user documentation included with the redistribution,
21
 
 *    if any, must include the following acknowledgment:
22
 
 *       "This product includes software developed by the
23
 
 *        Apache Software Foundation (http://www.apache.org/)."
24
 
 *    Alternately, this acknowledgment may appear in the software itself,
25
 
 *    if and wherever such third-party acknowledgments normally appear.
26
 
 *
27
 
 * 4. The names "Xerces" and "Apache Software Foundation" must
28
 
 *    not be used to endorse or promote products derived from this
29
 
 *    software without prior written permission. For written
30
 
 *    permission, please contact apache@apache.org.
31
 
 *
32
 
 * 5. Products derived from this software may not be called "Apache",
33
 
 *    nor may "Apache" appear in their name, without prior written
34
 
 *    permission of the Apache Software Foundation.
35
 
 *
36
 
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37
 
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38
 
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39
 
 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40
 
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41
 
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42
 
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43
 
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44
 
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45
 
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46
 
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47
 
 * SUCH DAMAGE.
48
 
 * ====================================================================
49
 
 *
50
 
 * This software consists of voluntary contributions made by many
51
 
 * individuals on behalf of the Apache Software Foundation and was
52
 
 * originally based on software copyright (c) 1999, International
53
 
 * Business Machines, Inc., http://www.apache.org.  For more
54
 
 * information on the Apache Software Foundation, please see
55
 
 * <http://www.apache.org/>.
 
2
 * Copyright 2001-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.
56
15
 */
57
16
 
58
17
package xni;
90
49
 *
91
50
 * @author Andy Clark, IBM
92
51
 *
93
 
 * @version $Id: Counter.java,v 1.15 2004/02/17 07:14:48 neeraj Exp $
 
52
 * @version $Id: Counter.java 345598 2005-11-18 23:16:34Z mrglavas $
94
53
 */
95
54
public class Counter
96
55
    extends XMLDocumentParser
121
80
    /** Schema full checking feature id (http://apache.org/xml/features/validation/schema-full-checking). */
122
81
    protected static final String SCHEMA_FULL_CHECKING_FEATURE_ID =
123
82
        "http://apache.org/xml/features/validation/schema-full-checking";
 
83
    
 
84
    /** Honour all schema locations feature id (http://apache.org/xml/features/honour-all-schemaLocations). */
 
85
    protected static final String HONOUR_ALL_SCHEMA_LOCATIONS_ID = 
 
86
        "http://apache.org/xml/features/honour-all-schemaLocations";
124
87
 
125
88
    // default settings
126
89
 
127
 
    /** Default parser configuration (org.apache.xerces.parsers.XML11Configuration). */
 
90
    /** Default parser configuration (org.apache.xerces.parsers.XIncludeAwareParserConfiguration). */
128
91
    protected static final String DEFAULT_PARSER_CONFIG =
129
 
        "org.apache.xerces.parsers.XML11Configuration";
 
92
        "org.apache.xerces.parsers.XIncludeAwareParserConfiguration";
130
93
 
131
94
    /** Default repetition (1). */
132
95
    protected static final int DEFAULT_REPETITION = 1;
145
108
 
146
109
    /** Default Schema full checking support (false). */
147
110
    protected static final boolean DEFAULT_SCHEMA_FULL_CHECKING = false;
 
111
    
 
112
    /** Default honour all schema locations (false). */
 
113
    protected static final boolean DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS = false;
148
114
 
149
115
    /** Default memory usage report (false). */
150
116
    protected static final boolean DEFAULT_MEMORY_USAGE = false;
398
364
        boolean validation = DEFAULT_VALIDATION;
399
365
        boolean schemaValidation = DEFAULT_SCHEMA_VALIDATION;
400
366
        boolean schemaFullChecking = DEFAULT_SCHEMA_FULL_CHECKING;
 
367
        boolean honourAllSchemaLocations = DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS;
401
368
        boolean memoryUsage = DEFAULT_MEMORY_USAGE;
402
369
        boolean tagginess = DEFAULT_TAGGINESS;
403
370
 
468
435
                    schemaFullChecking = option.equals("f");
469
436
                    continue;
470
437
                }
 
438
                if (option.equalsIgnoreCase("hs")) {
 
439
                    honourAllSchemaLocations = option.equals("hs");
 
440
                    continue;
 
441
                }
471
442
                if (option.equalsIgnoreCase("m")) {
472
443
                    memoryUsage = option.equals("m");
473
444
                    continue;
542
513
                    System.err.println("warning: Parser does not support feature ("+SCHEMA_FULL_CHECKING_FEATURE_ID+")");
543
514
                }
544
515
            }
 
516
            try {
 
517
                parserConfig.setFeature(HONOUR_ALL_SCHEMA_LOCATIONS_ID, honourAllSchemaLocations);
 
518
            }
 
519
            catch (XMLConfigurationException e) {
 
520
                if (e.getType() == XMLConfigurationException.NOT_SUPPORTED) {
 
521
                    System.err.println("warning: Parser does not support feature ("+HONOUR_ALL_SCHEMA_LOCATIONS_ID+")");
 
522
                }
 
523
            }
545
524
 
546
525
            // parse file
547
526
            try {
601
580
        System.err.println("              NOTE: Not supported by all parser configurations.");
602
581
        System.err.println("  -f  | -F    Turn on/off Schema full checking.");
603
582
        System.err.println("              NOTE: Requires use of -s and not supported by all parsers.");
 
583
        System.err.println("  -hs | -HS   Turn on/off honouring of all schema locations.");
 
584
        System.err.println("              NOTE: Requires use of -s and not supported by all parsers.");
604
585
        System.err.println("  -m  | -M    Turn on/off memory usage report.");
605
586
        System.err.println("  -t  | -T    Turn on/off \"tagginess\" report.");
606
587
        System.err.println("  --rem text  Output user defined comment before next parse.");
620
601
        System.err.println(DEFAULT_SCHEMA_VALIDATION ? "on" : "off");
621
602
        System.err.print("  Schema full checking:     ");
622
603
        System.err.println(DEFAULT_SCHEMA_FULL_CHECKING ? "on" : "off");
 
604
        System.err.print("  Honour all schema locations:     ");
 
605
        System.err.println(DEFAULT_HONOUR_ALL_SCHEMA_LOCATIONS ? "on" : "off");
623
606
        System.err.print("  Memory:     ");
624
607
        System.err.println(DEFAULT_MEMORY_USAGE ? "on" : "off");
625
608
        System.err.print("  Tagginess:  ");