KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > parsers > SAXParser


1 /*
2  * Copyright 2000-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 org.apache.xerces.parsers;
18
19 import org.apache.xerces.impl.Constants;
20 import org.apache.xerces.util.SymbolTable;
21 import org.apache.xerces.xni.grammars.XMLGrammarPool;
22 import org.apache.xerces.xni.parser.XMLParserConfiguration;
23
24 /**
25  * This is the main Xerces SAX parser class. It uses the abstract SAX
26  * parser with a document scanner, a dtd scanner, and a validator, as
27  * well as a grammar pool.
28  *
29  * @author Arnaud Le Hors, IBM
30  * @author Andy Clark, IBM
31  *
32  * @version $Id: SAXParser.java,v 1.39 2005/05/04 03:56:45 mrglavas Exp $
33  */

34 public class SAXParser
35     extends AbstractSAXParser {
36
37     //
38
// Constants
39
//
40

41     // features
42

43     /** Feature identifier: notify built-in refereces. */
44     protected static final String JavaDoc NOTIFY_BUILTIN_REFS =
45         Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_BUILTIN_REFS_FEATURE;
46
47     /** Recognized features. */
48     private static final String JavaDoc[] RECOGNIZED_FEATURES = {
49         NOTIFY_BUILTIN_REFS,
50     };
51
52     // properties
53

54     /** Property identifier: symbol table. */
55     protected static final String JavaDoc SYMBOL_TABLE =
56         Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY;
57
58     /** Property identifier: XML grammar pool. */
59     protected static final String JavaDoc XMLGRAMMAR_POOL =
60         Constants.XERCES_PROPERTY_PREFIX+Constants.XMLGRAMMAR_POOL_PROPERTY;
61
62     /** Recognized properties. */
63     private static final String JavaDoc[] RECOGNIZED_PROPERTIES = {
64         SYMBOL_TABLE,
65         XMLGRAMMAR_POOL,
66     };
67
68     //
69
// Constructors
70
//
71

72     /**
73      * Constructs a SAX parser using the specified parser configuration.
74      */

75     public SAXParser(XMLParserConfiguration config) {
76         super(config);
77     } // <init>(XMLParserConfiguration)
78

79     /**
80      * Constructs a SAX parser using the dtd/xml schema parser configuration.
81      */

82     public SAXParser() {
83         this(null, null);
84     } // <init>()
85

86     /**
87      * Constructs a SAX parser using the specified symbol table.
88      */

89     public SAXParser(SymbolTable symbolTable) {
90         this(symbolTable, null);
91     } // <init>(SymbolTable)
92

93     /**
94      * Constructs a SAX parser using the specified symbol table and
95      * grammar pool.
96      */

97     public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
98         super((XMLParserConfiguration)ObjectFactory.createObject(
99             "org.apache.xerces.xni.parser.XMLParserConfiguration",
100             "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"
101             ));
102
103         // set features
104
fConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
105         fConfiguration.setFeature(NOTIFY_BUILTIN_REFS, true);
106
107         // set properties
108
fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
109         if (symbolTable != null) {
110             fConfiguration.setProperty(SYMBOL_TABLE, symbolTable);
111         }
112         if (grammarPool != null) {
113             fConfiguration.setProperty(XMLGRAMMAR_POOL, grammarPool);
114         }
115
116     } // <init>(SymbolTable,XMLGrammarPool)
117

118 } // class SAXParser
119
Popular Tags