001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.xerces.parsers;
019:
020: import org.apache.xerces.impl.Constants;
021: import org.apache.xerces.util.SymbolTable;
022: import org.apache.xerces.xni.grammars.XMLGrammarPool;
023: import org.apache.xerces.xni.parser.XMLParserConfiguration;
024:
025: /**
026: * This is the main Xerces SAX parser class. It uses the abstract SAX
027: * parser with a document scanner, a dtd scanner, and a validator, as
028: * well as a grammar pool.
029: *
030: * @author Arnaud Le Hors, IBM
031: * @author Andy Clark, IBM
032: *
033: * @version $Id: SAXParser.java 447239 2006-09-18 05:08:26Z mrglavas $
034: */
035: public class SAXParser extends AbstractSAXParser {
036:
037: //
038: // Constants
039: //
040:
041: // features
042:
043: /** Feature identifier: notify built-in refereces. */
044: protected static final String NOTIFY_BUILTIN_REFS = Constants.XERCES_FEATURE_PREFIX
045: + Constants.NOTIFY_BUILTIN_REFS_FEATURE;
046:
047: /** Recognized features. */
048: private static final String[] RECOGNIZED_FEATURES = { NOTIFY_BUILTIN_REFS, };
049:
050: // properties
051:
052: /** Property identifier: symbol table. */
053: protected static final String SYMBOL_TABLE = Constants.XERCES_PROPERTY_PREFIX
054: + Constants.SYMBOL_TABLE_PROPERTY;
055:
056: /** Property identifier: XML grammar pool. */
057: protected static final String XMLGRAMMAR_POOL = Constants.XERCES_PROPERTY_PREFIX
058: + Constants.XMLGRAMMAR_POOL_PROPERTY;
059:
060: /** Recognized properties. */
061: private static final String[] RECOGNIZED_PROPERTIES = {
062: SYMBOL_TABLE, XMLGRAMMAR_POOL, };
063:
064: //
065: // Constructors
066: //
067:
068: /**
069: * Constructs a SAX parser using the specified parser configuration.
070: */
071: public SAXParser(XMLParserConfiguration config) {
072: super (config);
073: } // <init>(XMLParserConfiguration)
074:
075: /**
076: * Constructs a SAX parser using the dtd/xml schema parser configuration.
077: */
078: public SAXParser() {
079: this (null, null);
080: } // <init>()
081:
082: /**
083: * Constructs a SAX parser using the specified symbol table.
084: */
085: public SAXParser(SymbolTable symbolTable) {
086: this (symbolTable, null);
087: } // <init>(SymbolTable)
088:
089: /**
090: * Constructs a SAX parser using the specified symbol table and
091: * grammar pool.
092: */
093: public SAXParser(SymbolTable symbolTable, XMLGrammarPool grammarPool) {
094: super (
095: (XMLParserConfiguration) ObjectFactory
096: .createObject(
097: "org.apache.xerces.xni.parser.XMLParserConfiguration",
098: "org.apache.xerces.parsers.XIncludeAwareParserConfiguration"));
099:
100: // set features
101: fConfiguration.addRecognizedFeatures(RECOGNIZED_FEATURES);
102: fConfiguration.setFeature(NOTIFY_BUILTIN_REFS, true);
103:
104: // set properties
105: fConfiguration.addRecognizedProperties(RECOGNIZED_PROPERTIES);
106: if (symbolTable != null) {
107: fConfiguration.setProperty(SYMBOL_TABLE, symbolTable);
108: }
109: if (grammarPool != null) {
110: fConfiguration.setProperty(XMLGRAMMAR_POOL, grammarPool);
111: }
112:
113: } // <init>(SymbolTable,XMLGrammarPool)
114:
115: } // class SAXParser
|