Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/xerces/framework/XMLParser.java


1   /*
2    * The Apache Software License, Version 1.1
3    *
4    *
5    * Copyright (c) 1999,2000 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/>.
56   */
57  
58  package org.apache.xerces.framework;
59  
60  import java.io.InputStream;
61  import java.io.IOException;
62  import java.io.Reader;
63  import java.util.Locale;
64  
65  import org.apache.xerces.readers.DefaultEntityHandler;
66  import org.apache.xerces.readers.XMLDeclRecognizer;
67  import org.apache.xerces.readers.XMLEntityHandler;
68  import org.apache.xerces.readers.XMLEntityReaderFactory;
69  import org.apache.xerces.utils.ChunkyCharArray;
70  import org.apache.xerces.utils.StringPool;
71  import org.apache.xerces.utils.XMLMessageProvider;
72  import org.apache.xerces.utils.XMLMessages;
73  import org.apache.xerces.utils.ImplementationMessages;
74  import org.apache.xerces.validators.common.GrammarResolver;
75  import org.apache.xerces.validators.common.GrammarResolverImpl;
76  import org.apache.xerces.validators.common.XMLValidator;
77  import org.apache.xerces.validators.datatype.DatatypeMessageProvider;
78  import org.apache.xerces.validators.datatype.DatatypeValidatorFactoryImpl;
79  import org.apache.xerces.validators.schema.SchemaMessageProvider;
80  
81  import org.xml.sax.EntityResolver;
82  import org.xml.sax.ErrorHandler;
83  import org.xml.sax.InputSource;
84  import org.xml.sax.Locator;
85  import org.xml.sax.SAXException;
86  import org.xml.sax.SAXNotRecognizedException;
87  import org.xml.sax.SAXNotSupportedException;
88  import org.xml.sax.SAXParseException;
89  
90  /**
91   * This is the base class of all standard parsers.
92   *
93   * @version $Id: XMLParser.java,v 1.4 2000/10/07 18:06:53 markd Exp $
94   */
95  public abstract class XMLParser 
96      implements XMLErrorReporter, XMLDocumentHandler.DTDHandler {
97  
98      //
99      // Constants
100     //
101 
102     // protected
103 
104     /** SAX2 features prefix (http://xml.org/sax/features/). */
105     protected static final String SAX2_FEATURES_PREFIX = "http://xml.org/sax/features/";
106 
107     /** SAX2 properties prefix (http://xml.org/sax/properties/). */
108     protected static final String SAX2_PROPERTIES_PREFIX = "http://xml.org/sax/properties/";
109 
110     /** Xerces features prefix (http://apache.org/xml/features/). */
111     protected static final String XERCES_FEATURES_PREFIX = "http://apache.org/xml/features/";
112 
113     /** Xerces properties prefix (http://apache.org/xml/properties/). */
114     protected static final String XERCES_PROPERTIES_PREFIX = "http://apache.org/xml/properties/";
115 
116     // private
117 
118     /** Features recognized by this parser. */
119     private static final String RECOGNIZED_FEATURES[] = {
120         // SAX2 core
121         "http://xml.org/sax/features/validation",
122         "http://xml.org/sax/features/external-general-entities",
123         "http://xml.org/sax/features/external-parameter-entities",
124         "http://xml.org/sax/features/namespaces",
125         // Xerces
126         "http://apache.org/xml/features/validation/schema",
127         "http://apache.org/xml/features/validation/dynamic",
128         "http://apache.org/xml/features/validation/default-attribute-values",
129         "http://apache.org/xml/features/validation/validate-content-models",
130         "http://apache.org/xml/features/validation/validate-datatypes",
131         "http://apache.org/xml/features/validation/warn-on-duplicate-attdef",
132         "http://apache.org/xml/features/validation/warn-on-undeclared-elemdef",
133         "http://apache.org/xml/features/allow-java-encodings",
134         "http://apache.org/xml/features/continue-after-fatal-error",
135         "http://apache.org/xml/features/nonvalidating/load-dtd-grammar"
136     };
137 
138     /** Properties recognized by this parser. */
139     private static final String RECOGNIZED_PROPERTIES[] = {
140         // SAX2 core
141         "http://xml.org/sax/properties/xml-string",
142         // Xerces
143     };
144 
145     // debugging
146 
147     /** Set to true and recompile to print exception stack trace. */
148     private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
149 
150     //
151     // Data
152     //
153 
154     protected GrammarResolver fGrammarResolver = null;
155 
156     // state
157 
158     protected boolean fParseInProgress = false;
159     private boolean fNeedReset = false;
160 
161     // features
162 
163     /** Continue after fatal error. */
164     private boolean fContinueAfterFatalError = false;
165 
166     // properties
167 
168     /** Error handler. */
169     private ErrorHandler fErrorHandler = null;
170 
171     // other
172 
173     private Locale fLocale = null;
174 
175     // error information
176 
177     private static XMLMessageProvider fgXMLMessages = new XMLMessages();
178     private static XMLMessageProvider fgImplementationMessages = new ImplementationMessages();
179     private static XMLMessageProvider fgSchemaMessages = new SchemaMessageProvider();
180     private static XMLMessageProvider fgDatatypeMessages= new DatatypeMessageProvider();
181 
182     //
183     //
184     //
185     protected StringPool fStringPool = null;
186     protected XMLErrorReporter fErrorReporter = null;
187     protected DefaultEntityHandler fEntityHandler = null;
188     protected XMLDocumentScanner fScanner = null;
189     protected XMLValidator fValidator = null;
190 
191     //
192     // Constructors
193     //
194 
195     /**
196      * Constructor
197      */
198     protected XMLParser() {
199         fStringPool = new StringPool();
200         fErrorReporter = this;
201         fEntityHandler = new DefaultEntityHandler(fStringPool, fErrorReporter);
202         fScanner = new XMLDocumentScanner(fStringPool, fErrorReporter, fEntityHandler, new ChunkyCharArray(fStringPool));
203         fValidator = new XMLValidator(fStringPool, fErrorReporter, fEntityHandler, fScanner);
204         fGrammarResolver = new GrammarResolverImpl();
205         fScanner.setGrammarResolver(fGrammarResolver);
206         fValidator.setGrammarResolver(fGrammarResolver);
207         try {
208             //JR-defect 48 fix - turn on Namespaces
209             setNamespaces(true);
210         }
211         catch (Exception e) {
212             // ignore
213         }
214     }
215 
216     /**
217      * Set char data processing preference and handlers.
218      */
219     protected void initHandlers(boolean sendCharDataAsCharArray,
220                                 XMLDocumentHandler docHandler,
221                                 XMLDocumentHandler.DTDHandler dtdHandler)
222     {
223         fValidator.initHandlers(sendCharDataAsCharArray, docHandler, dtdHandler);
224         fScanner.setDTDHandler(this);
225     }
226 
227     //
228     // Public methods
229     //
230 
231     // features and properties
232 
233     /**
234      * Returns a list of features that this parser recognizes.
235      * This method will never return null; if no features are
236      * recognized, this method will return a zero length array.
237      *
238      * @see #isFeatureRecognized
239      * @see #setFeature
240      * @see #getFeature
241      */
242     public String[] getFeaturesRecognized() {
243         return RECOGNIZED_FEATURES;
244     }
245 
246     /**
247      * Returns true if the specified feature is recognized.
248      *
249      * @see #getFeaturesRecognized
250      * @see #setFeature
251      * @see #getFeature
252      */
253     public boolean isFeatureRecognized(String featureId) {
254         String[] recognizedFeatures = getFeaturesRecognized();
255         for (int i = 0; i < recognizedFeatures.length; i++) {
256             if (featureId.equals(recognizedFeatures[i]))
257                 return true;
258         }
259         return false;
260     }
261 
262     /**
263      * Returns a list of properties that this parser recognizes.
264      * This method will never return null; if no properties are
265      * recognized, this method will return a zero length array.
266      *
267      * @see #isPropertyRecognized
268      * @see #setProperty
269      * @see #getProperty
270      */
271     public String[] getPropertiesRecognized() {
272         return RECOGNIZED_PROPERTIES;
273     }
274 
275     /**
276      * Returns true if the specified property is recognized.
277      *
278      * @see #getPropertiesRecognized
279      * @see #setProperty
280      * @see #getProperty
281      */
282     public boolean isPropertyRecognized(String propertyId) {
283         String[] recognizedProperties = getPropertiesRecognized();
284         for (int i = 0; i < recognizedProperties.length; i++) {
285             if (propertyId.equals(recognizedProperties[i]))
286                 return true;
287         }
288         return false;
289     }
290 
291     // initialization
292 
293     /**
294      * Setup for application-driven parsing.
295      *
296      * @param source the input source to be parsed.
297      * @see #parseSome
298      */
299     public boolean parseSomeSetup(InputSource source) throws Exception {
300         if (fNeedReset)
301             resetOrCopy();
302         fParseInProgress = true;
303         fNeedReset = true;
304         return fEntityHandler.startReadingFromDocument(source);
305     }
306 
307     /**
308      * Application-driven parsing.
309      *
310      * @see #parseSomeSetup
311      */
312     public boolean parseSome() throws Exception {
313         if (!fScanner.parseSome(false)) {
314             fParseInProgress = false;
315             return false;
316         }
317         return true;
318     }
319 
320     // resetting
321 
322     /** Reset parser instance so that it can be reused. */
323     public void reset() throws Exception {
324         fGrammarResolver.clearGrammarResolver();
325         fStringPool.reset();
326         fEntityHandler.reset(fStringPool);
327         fScanner.reset(fStringPool, new ChunkyCharArray(fStringPool));
328         fValidator.reset(fStringPool);
329         fNeedReset = false;
330     }
331 
332     // properties (the normal kind)
333 
334     /**
335      * return the locator being used by the parser
336      *
337      * @return the parser's active locator
338      */
339     public final Locator getLocator() {
340         return fEntityHandler;
341     }
342 
343     /**
344      * Set the reader factory.
345      */
346     public void setReaderFactory(XMLEntityReaderFactory readerFactory) {
347         fEntityHandler.setReaderFactory(readerFactory);
348     }
349 
350     /**
351      * Adds a recognizer.
352      *
353      * @param recognizer The XML recognizer to add.
354      */
355     public void addRecognizer(XMLDeclRecognizer recognizer) {
356         fEntityHandler.addRecognizer(recognizer);
357     }
358 
359     //
360     // Protected methods
361     //
362 
363     // SAX2 core features
364 
365     /**
366      * Sets whether the parser validates.
367      * <p>
368      * This method is the equivalent to the feature:
369      * <pre>
370      * http://xml.org/sax/features/validation
371      * </pre>
372      *
373      * @param validate True to validate; false to not validate.
374      *
375      * @see #getValidation
376      * @see #setFeature
377      */
378     protected void setValidation(boolean validate) 
379         throws SAXNotRecognizedException, SAXNotSupportedException {
380         if (fParseInProgress) {
381             throw new SAXNotSupportedException("PAR004 Cannot setFeature(http://xml.org/sax/features/validation): parse is in progress.\n"+
382                                                "http://xml.org/sax/features/validation");
383         }
384         try {
385             // REVISIT: [Q] Should the scanner tell the validator that
386             //              validation is on? -Ac
387             fScanner.setValidationEnabled(validate);
388             fValidator.setValidationEnabled(validate);
389         }
390         catch (Exception ex) {
391             throw new SAXNotSupportedException(ex.getMessage());
392         }
393     }
394 
395     /**
396      * Returns true if validation is turned on.
397      *
398      * @see #setValidation
399      */
400     protected boolean getValidation() 
401         throws SAXNotRecognizedException, SAXNotSupportedException {
402         return fValidator.getValidationEnabled();
403     }
404 
405     /**
406      * <b>Note: Currently, this parser always expands external general
407      * entities.</b> Setting this feature to false will throw a
408      * SAXNotSupportedException.
409      * <p>
410      * Sets whether external general entities are expanded.
411      * <p>
412      * This method is the equivalent to the feature:
413      * <pre>
414      * http://xml.org/sax/features/external-general-entities
415      * </pre>
416      *
417      * @param expand True to expand external general entities; false
418      *               to not expand.
419      *
420      * @see #getExternalGeneralEntities
421      * @see #setFeature
422      */
423     protected void setExternalGeneralEntities(boolean expand)
424         throws SAXNotRecognizedException, SAXNotSupportedException {
425         if (fParseInProgress) {
426             throw new SAXNotSupportedException("PAR004 Cannot setFeature(http://xml.org/sax/features/external-general-entities): parse is in progress.\n"+
427                                                "http://xml.org/sax/features/external-general-entities");
428         }
429         if (!expand) {
430             throw new SAXNotSupportedException("http://xml.org/sax/features/external-general-entities");
431         }
432     }
433 
434     /**
435      * <b>Note: This feature is always true.</b>
436      * <p>
437      * Returns true if external general entities are expanded.
438      *
439      * @see #setExternalGeneralEntities
440      */
441     protected boolean getExternalGeneralEntities() 
442         throws SAXNotRecognizedException, SAXNotSupportedException {
443         return true;
444     }
445 
446     /**
447      * <b>Note: Currently, this parser always expands external parameter
448      * entities.</b> Setting this feature to false will throw a
449      * SAXNotSupportedException.
450      * <p>
451      * Sets whether external parameter entities are expanded.
452      * <p>
453      * This method is the equivalent to the feature:
454      * <pre>
455      * http://xml.org/sax/features/external-parameter-entities
456      * </pre>
457      *
458      * @param expand True to expand external parameter entities; false
459      *               to not expand.
460      *
461      * @see #getExternalParameterEntities
462      * @see #setFeature
463      */
464     protected void setExternalParameterEntities(boolean expand)
465         throws SAXNotRecognizedException, SAXNotSupportedException {
466         if (fParseInProgress) {
467             throw new SAXNotSupportedException("PAR004 Cannot setFeature(http://xml.org/sax/features/external-general-entities): parse is in progress.\n"+
468                                                "http://xml.org/sax/features/external-general-entities");
469         }
470         if (!expand) {
471             throw new SAXNotSupportedException("http://xml.org/sax/features/external-parameter-entities");
472         }
473     }
474 
475     /**
476      * <b>Note: This feature is always true.</b>
477      * <p>
478      * Returns true if external parameter entities are expanded.
479      *
480      * @see #setExternalParameterEntities
481      */
482     protected boolean getExternalParameterEntities() 
483         throws SAXNotRecognizedException, SAXNotSupportedException {
484         return true;
485     }
486 
487     /**
488      * Sets whether the parser preprocesses namespaces.
489      * <p>
490      * This method is the equivalent to the feature:
491      * <pre>
492      * http://xml.org/sax/features/namespaces
493      * <pre>
494      *
495      * @param process True to process namespaces; false to not process.
496      *
497      * @see #getNamespaces
498      * @see #setFeature
499      */
500     protected void setNamespaces(boolean process) 
501         throws SAXNotRecognizedException, SAXNotSupportedException {
502         if (fParseInProgress) {
503             throw new SAXNotSupportedException("PAR004 Cannot setFeature(http://xml.org/sax/features/namespaces): parse is in progress.\n"+
504                                                "http://xml.org/sax/features/namespaces");
505         }
506         fScanner.setNamespacesEnabled(process);
507         // REVISIT: [Q] Should the scanner tell the validator that namespace
508         //              processing is on? -Ac
509         fValidator.setNamespacesEnabled(process);
510     }
511 
512     /**
513      * Returns true if the parser preprocesses namespaces.
514      *
515      * @see #setNamespaces
516      */
517     protected boolean getNamespaces() 
518         throws SAXNotRecognizedException, SAXNotSupportedException {
519         return fValidator.getNamespacesEnabled();
520     }
521 
522     // Xerces features
523 
524     /**
525      * Allows the user to turn Schema support on/off.
526      * <p>
527      * This method is equivalent to the feature:
528      * <pre>
529      * http://apache.org/xml/features/validation/schema
530      * </pre>
531      *
532      * @param schema True to turn on Schema support; false to turn it off.
533      *
534      * @see #getValidationSchema
535      * @see #setFeature
536      */
537     protected void setValidationSchema(boolean schema) 
538         throws SAXNotRecognizedException, SAXNotSupportedException {
539         if (fParseInProgress) {
540             // REVISIT: Localize message
541             throw new SAXNotSupportedException("http://apache.org/xml/features/validation/schema: parse is in progress");
542         }
543         fValidator.setSchemaValidationEnabled(schema);
544     }
545 
546     /**
547      * Returns true if Schema support is turned on.
548      *
549      * @see #setValidationSchema
550      */
551     protected boolean getValidationSchema() 
552         throws SAXNotRecognizedException, SAXNotSupportedException {
553         return fValidator.getSchemaValidationEnabled();
554     }
555 
556     /**
557      * Allows the parser to validate a document only when it contains a
558      * grammar. Validation is turned on/off based on each document
559      * instance, automatically.
560      * <p>
561      * This method is the equivalent to the feature:
562      * <pre>
563      * http://apache.org/xml/features/validation/dynamic
564      * </pre>
565      *
566      * @param dynamic True to dynamically validate documents; false to
567      *                validate based on the validation feature.
568      *
569      * @see #getValidationDynamic
570      * @see #setFeature
571      */
572     protected void setValidationDynamic(boolean dynamic) 
573         throws SAXNotRecognizedException, SAXNotSupportedException {
574         if (fParseInProgress) {
575             // REVISIT: Localize message
576             throw new SAXNotSupportedException("http://apache.org/xml/features/validation/dynamic: parse is in progress");
577         }
578         try {
579             fValidator.setDynamicValidationEnabled(dynamic);
580         }
581         catch (Exception ex) {
582             throw new SAXNotSupportedException(ex.getMessage());
583         }
584     }
585 
586     /**
587      * Returns true if validation is based on whether a document
588      * contains a grammar.
589      *
590      * @see #setValidationDynamic
591      */
592     protected boolean getValidationDynamic() 
593         throws SAXNotRecognizedException, SAXNotSupportedException {
594         return fValidator.getDynamicValidationEnabled();
595     }
596     /**
597      * Allows the parser to have the choice to load DTD grammar when 
598      * validation is off.
599      * <p>
600      * This method is the equivalent to the feature:
601      * <pre>
602      * http://apache.org/xml/features/nonvalidating/load-dtd-grammar
603      * </pre>
604      *
605      * @param loadDTDGrammar True to turn on the feature; false to
606      *                turn off the feature.
607      *
608      * @see #getLoadDTDGrammar
609      * @see #setFeature
610      */
611     protected void setLoadDTDGrammar(boolean loadDTDGrammar) 
612         throws SAXNotRecognizedException, SAXNotSupportedException {
613         if (fParseInProgress) {
614             // REVISIT: Localize message
615             throw new SAXNotSupportedException("http://apache.org/xml/features/nonvalidating/load-dtd-grammar: parse is in progress");
616         }
617         try {
618             fValidator.setLoadDTDGrammar(loadDTDGrammar);
619         }
620         catch (Exception ex) {
621             throw new SAXNotSupportedException(ex.getMessage());
622         }
623     }
624 
625     /**
626      * Returns true if load DTD grammar is turned on in the XMLValiator.
627      *
628      * @see #setLoadDTDGrammar
629      */
630     protected boolean getLoadDTDGrammar() 
631         throws SAXNotRecognizedException, SAXNotSupportedException {
632         return fValidator.getLoadDTDGrammar();
633     }
634 
635     /**
636      * Sets whether an error is emitted when an attribute is redefined
637      * in the grammar.
638      * <p>
639      * This method is the equivalent to the feature:
640      * <pre>
641      * http://apache.org/xml/features/validation/warn-on-duplicate-attdef
642      * </pre>
643      *
644      * @param warn True to warn; false to not warn.
645      *
646      * @see #getValidationWarnOnDuplicateAttdef
647      * @see #setFeature
648      */
649     protected void setValidationWarnOnDuplicateAttdef(boolean warn)
650         throws SAXNotRecognizedException, SAXNotSupportedException {
651         fValidator.setWarningOnDuplicateAttDef(warn);
652     }
653 
654     /**
655      * Returns true if an error is emitted when an attribute is redefined
656      * in the grammar.
657      *
658      * @see #setValidationWarnOnDuplicateAttdef
659      */
660     protected boolean getValidationWarnOnDuplicateAttdef()
661         throws SAXNotRecognizedException, SAXNotSupportedException {
662         return fValidator.getWarningOnDuplicateAttDef();
663     }
664 
665     /**
666      * Sets whether the parser emits an error when an element's content
667      * model references an element by name that is not declared in the
668      * grammar.
669      * <p>
670      * This method is the equivalent to the feature:
671      * <pre>
672      * http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
673      * </pre>
674      *
675      * @param warn True to warn; false to not warn.
676      *
677      * @see #getValidationWarnOnUndeclaredElemdef
678      * @see #setFeature
679      */
680     protected void setValidationWarnOnUndeclaredElemdef(boolean warn)
681         throws SAXNotRecognizedException, SAXNotSupportedException {
682         fValidator.setWarningOnUndeclaredElements(warn);
683     }
684 
685     /**
686      * Returns true if the parser emits an error when an undeclared
687      * element is referenced in the grammar.
688      *
689      * @see #setValidationWarnOnUndeclaredElemdef
690      */
691     protected boolean getValidationWarnOnUndeclaredElemdef()
692         throws SAXNotRecognizedException, SAXNotSupportedException {
693         return fValidator.getWarningOnUndeclaredElements();
694     }
695 
696     /**
697      * Allows the use of Java encoding names in the XMLDecl and TextDecl
698      * lines in an XML document.
699      * <p>
700      * This method is the equivalent to the feature:
701      * <pre>
702      * http://apache.org/xml/features/allow-java-encodings
703      * </pre>
704      *
705      * @param allow True to allow Java encoding names; false to disallow.
706      *
707      * @see #getAllowJavaEncodings
708      * @see #setFeature
709      */
710     protected void setAllowJavaEncodings(boolean allow) 
711         throws SAXNotRecognizedException, SAXNotSupportedException {
712         fEntityHandler.setAllowJavaEncodings(allow);
713     }
714 
715     /**
716      * Returns true if Java encoding names are allowed in the XML document.
717      *
718      * @see #setAllowJavaEncodings
719      */
720     protected boolean getAllowJavaEncodings() 
721         throws SAXNotRecognizedException, SAXNotSupportedException {
722         return fEntityHandler.getAllowJavaEncodings();
723     }
724 
725     /**
726      * Allows the parser to continue after a fatal error. Normally, a
727      * fatal error would stop the parse.
728      * <p>
729      * This method is the equivalent to the feature:
730      * <pre>
731      * http://apache.org/xml/features/continue-after-fatal-error
732      * </pre>
733      *
734      * @param continueAfterFatalError True to continue; false to stop on
735      *                                fatal error.
736      *
737      * @see #getContinueAfterFatalError
738      * @see #setFeature
739      */
740     protected void setContinueAfterFatalError(boolean continueAfterFatalError)
741         throws SAXNotRecognizedException, SAXNotSupportedException {
742         fContinueAfterFatalError = continueAfterFatalError;
743     }
744 
745     /**
746      * Returns true if the parser continues after a fatal error.
747      *
748      * @see #setContinueAfterFatalError
749      */
750     protected boolean getContinueAfterFatalError() 
751         throws SAXNotRecognizedException, SAXNotSupportedException {
752         return fContinueAfterFatalError;
753     }
754 
755     // SAX2 core properties
756 
757     /**
758      * Set the separator to be used between the URI part of a name and the
759      * local part of a name when namespace processing is being performed
760      * (see the http://xml.org/sax/features/namespaces feature).  By default,
761      * the separator is a single space.
762      * <p>
763      * This property may not be set while a parse is in progress (throws a
764      * SAXNotSupportedException).
765      * <p>
766      * This method is the equivalent to the property:
767      * <pre>
768      * http://xml.org/sax/properties/namespace-sep
769      * </pre>
770      *
771      * @param separator The new namespace separator.
772      *
773      * @see #getNamespaceSep
774      * @see #setProperty
775      */
776     /***
777     protected void setNamespaceSep(String separator) 
778         throws SAXNotRecognizedException, SAXNotSupportedException {
779         // REVISIT: Ask someone what it could possibly hurt to allow
780         //          the application to change this in mid-parse.
781         if (fParseInProgress) {
782             throw new SAXNotSupportedException("http://xml.org/sax/properties/namespace-sep: parse is in progress");
783         }
784         fNamespaceSep = separator;
785     }
786     /***/
787 
788     /**
789      * Returns the namespace separator.
790      *
791      * @see #setNamespaceSep
792      */
793     /***
794     protected String getNamespaceSep() 
795         throws SAXNotRecognizedException, SAXNotSupportedException {
796         return fNamespaceSep;
797     }
798     /***/
799 
800     /**
801      * This method is the equivalent to the property:
802      * <pre>
803      * http://xml.org/sax/properties/xml-string
804      * </pre>
805      *
806      * @see #getProperty
807      */
808     protected String getXMLString() 
809         throws SAXNotRecognizedException, SAXNotSupportedException {
810         throw new SAXNotSupportedException("http://xml.org/sax/properties/xml-string");
811     }
812 
813     // resetting
814 
815     /**
816      * Reset or copy parser
817      * Allows parser instance reuse
818      */
819     protected void resetOrCopy() throws Exception {
820         fStringPool = new StringPool();
821         fEntityHandler.reset(fStringPool);
822         fScanner.reset(fStringPool, new ChunkyCharArray(fStringPool));
823         fValidator.resetOrCopy(fStringPool);
824         fNeedReset = false;
825         fGrammarResolver = new GrammarResolverImpl();
826         fScanner.setGrammarResolver(fGrammarResolver);
827         fValidator.setGrammarResolver(fGrammarResolver);
828         DatatypeValidatorFactoryImpl.getDatatypeRegistry().resetRegistry();
829     }
830 
831     //
832     // Parser/XMLReader methods
833     //
834     // NOTE: This class does *not* implement the org.xml.sax.Parser
835     //       interface but it does share some common methods. -Ac
836 
837     // handlers
838 
839     /**
840      * Sets the resolver used to resolve external entities. The EntityResolver
841      * interface supports resolution of public and system identifiers.
842      *
843      * @param resolver The new entity resolver. Passing a null value will
844      *                 uninstall the currently installed resolver.
845      */
846     public void setEntityResolver(EntityResolver resolver) {
847         fEntityHandler.setEntityResolver(resolver);
848     }
849 
850     /**
851      * Return the current entity resolver.
852      *
853      * @return The current entity resolver, or null if none
854      *         has been registered.
855      * @see #setEntityResolver
856      */
857     public EntityResolver getEntityResolver() {
858         return fEntityHandler.getEntityResolver();
859     }
860 
861     /**
862      * Sets the error handler.
863      *
864      * @param handler The new error handler.
865      */
866     public void setErrorHandler(ErrorHandler handler) {
867         fErrorHandler = handler;
868     }
869 
870     /**
871      * Return the current error handler.
872      *
873      * @return The current error handler, or null if none
874      *         has been registered.
875      * @see #setErrorHandler
876      */
877     public ErrorHandler getErrorHandler() {
878         return fErrorHandler;
879     }
880 
881     // parsing
882 
883     /**
884      * Parses the specified input source.
885      *
886      * @param source The input source.
887      *
888      * @exception org.xml.sax.SAXException Throws exception on SAX error.
889      * @exception java.io.IOException Throws exception on i/o error.
890      */
891     public void parse(InputSource source)
892         throws SAXException, IOException {
893 
894         if (fParseInProgress) {
895             throw new org.xml.sax.SAXException("FWK005 parse may not be called while parsing."); // REVISIT - need to add new error message
896         }
897 
898         try {
899             if (parseSomeSetup(source)) {
900                 fScanner.parseSome(true);
901             }
902             fParseInProgress = false;
903         } catch (org.xml.sax.SAXException ex) {
904             fParseInProgress = false;
905             if (PRINT_EXCEPTION_STACK_TRACE)
906                 ex.printStackTrace();
907             throw ex;
908         } catch (IOException ex) {
909             fParseInProgress = false;
910             if (PRINT_EXCEPTION_STACK_TRACE)
911                 ex.printStackTrace();
912             throw ex;
913         } catch (Exception ex) {
914             fParseInProgress = false;
915             if (PRINT_EXCEPTION_STACK_TRACE)
916                 ex.printStackTrace();
917             throw new org.xml.sax.SAXException(ex);
918         }
919 
920     } // parse(InputSource)
921 
922     /**
923      * Parses the input source specified by the given system identifier.
924      * <p>
925      * This method is equivalent to the following:
926      * <pre>
927      *     parse(new InputSource(systemId));
928      * </pre>
929      *
930      * @param source The input source.
931      *
932      * @exception org.xml.sax.SAXException Throws exception on SAX error.
933      * @exception java.io.IOException Throws exception on i/o error.
934      */
935     public void parse(String systemId)
936         throws SAXException, IOException {
937 
938         InputSource source = new InputSource(systemId);
939         parse(source);
940         try {
941             Reader reader = source.getCharacterStream();
942             if (reader != null) {
943                 reader.close();
944             }
945             else {
946                 InputStream is = source.getByteStream();
947                 if (is != null) {
948                     is.close();
949                 }
950             }
951         }
952         catch (IOException e) {
953             // ignore
954         }
955 
956     } // parse(String)
957 
958     // locale
959 
960     /**
961      * Set the locale to use for messages.
962      *
963      * @param locale The locale object to use for localization of messages.
964      *
965      * @exception SAXException An exception thrown if the parser does not
966      *                         support the specified locale.
967      *
968      * @see org.xml.sax.Parser
969      */
970     public void setLocale(Locale locale) throws SAXException {
971 
972         if (fParseInProgress) {
973             throw new org.xml.sax.SAXException("FWK006 setLocale may not be called while parsing"); // REVISIT - need to add new error message
974         }
975 
976         fLocale = locale;
977         fgXMLMessages.setLocale(locale);
978         fgImplementationMessages.setLocale(locale);
979 
980     } // setLocale(Locale)
981 
982     //
983     // XMLErrorReporter methods
984     //
985 
986     /**
987      * Report an error.
988      *
989      * @param locator Location of error.
990      * @param errorDomain The error domain.
991      * @param majorCode The major code of the error.
992      * @param minorCode The minor code of the error.
993      * @param args Arguments for replacement text.
994      * @param errorType The type of the error.
995      *
996      * @exception Exception Thrown on error.
997      *
998      * @see XMLErrorReporter#ERRORTYPE_WARNING
999      * @see XMLErrorReporter#ERRORTYPE_FATAL_ERROR
1000     */
1001    public void reportError(Locator locator, String errorDomain,
1002                            int majorCode, int minorCode, Object args[],
1003                            int errorType) throws Exception {
1004
1005        // create the appropriate message
1006        SAXParseException spe;
1007        if (errorDomain.equals(XMLMessages.XML_DOMAIN)) {
1008            spe = new SAXParseException(fgXMLMessages.createMessage(fLocale, majorCode, minorCode, args), locator);
1009        }
1010        else if (errorDomain.equals(XMLMessages.XMLNS_DOMAIN)) {
1011            spe = new SAXParseException(fgXMLMessages.createMessage(fLocale, majorCode, minorCode, args), locator);
1012        }
1013        else if (errorDomain.equals(ImplementationMessages.XERCES_IMPLEMENTATION_DOMAIN)) {
1014            spe = new SAXParseException(fgImplementationMessages.createMessage(fLocale, majorCode, minorCode, args), locator);
1015        } else if (errorDomain.equals(SchemaMessageProvider.SCHEMA_DOMAIN)) {
1016            spe = new SAXParseException(fgSchemaMessages.createMessage(fLocale, majorCode, minorCode, args), locator);
1017        } else if (errorDomain.equals(DatatypeMessageProvider.DATATYPE_DOMAIN)) {
1018            spe = new SAXParseException(fgDatatypeMessages.createMessage(fLocale, majorCode, minorCode, args), locator);
1019        } else {
1020            throw new RuntimeException("FWK007 Unknown error domain \"" + errorDomain + "\"."+"\n"+errorDomain);
1021        }
1022
1023        // default error handling
1024        if (fErrorHandler == null) {
1025            if (errorType == XMLErrorReporter.ERRORTYPE_FATAL_ERROR &&
1026                !fContinueAfterFatalError) {
1027                throw spe;
1028            }
1029            return;
1030        }
1031
1032        // make appropriate callback
1033        if (errorType == XMLErrorReporter.ERRORTYPE_WARNING) {
1034            fErrorHandler.warning(spe);
1035        }
1036        else if (errorType == XMLErrorReporter.ERRORTYPE_FATAL_ERROR) {
1037            fErrorHandler.fatalError(spe);
1038            if (!fContinueAfterFatalError) {
1039                Object[] fatalArgs = { spe.getMessage() };
1040                throw new SAXException(fgImplementationMessages.createMessage(fLocale, ImplementationMessages.FATAL_ERROR, 0, fatalArgs));
1041            }
1042        }
1043        else {
1044            fErrorHandler.error(spe);
1045        }
1046
1047    } // reportError(Locator,String,int,int,Object[],int)
1048
1049    //
1050    // XMLReader methods
1051    //
1052
1053    /**
1054     * Set the state of a feature.
1055     *
1056     * Set the state of any feature in a SAX2 parser.  The parser
1057     * might not recognize the feature, and if it does recognize
1058     * it, it might not be able to fulfill the request.
1059     *
1060     * @param featureId The unique identifier (URI) of the feature.
1061     * @param state The requested state of the feature (true or false).
1062     *
1063     * @exception org.xml.sax.SAXNotRecognizedException If the
1064     *            requested feature is not known.
1065     * @exception org.xml.sax.SAXNotSupportedException If the
1066     *            requested feature is known, but the requested
1067     *            state is not supported.
1068     * @exception org.xml.sax.SAXException If there is any other
1069     *            problem fulfilling the request.
1070     */
1071    public void setFeature(String featureId, boolean state)
1072        throws SAXNotRecognizedException, SAXNotSupportedException {
1073
1074        //
1075        // SAX2 Features
1076        //
1077
1078        if (featureId.startsWith(SAX2_FEATURES_PREFIX)) {
1079            String feature = featureId.substring(SAX2_FEATURES_PREFIX.length());
1080            //
1081            // http://xml.org/sax/features/validation
1082            //   Validate (true) or don't validate (false).
1083            //
1084            if (feature.equals("validation")) {
1085                setValidation(state);
1086                return;
1087            }
1088            //
1089            // http://xml.org/sax/features/external-general-entities
1090            //   Expand external general entities (true) or don't expand (false).
1091            //
1092            if (feature.equals("external-general-entities")) {
1093                setExternalGeneralEntities(state);
1094                return;
1095            }
1096            //
1097            // http://xml.org/sax/features/external-parameter-entities
1098            //   Expand external parameter entities (true) or don't expand (false).
1099            //
1100            if (feature.equals("external-parameter-entities")) {
1101                setExternalParameterEntities(state);
1102                return;
1103            }
1104            //
1105            // http://xml.org/sax/features/namespaces
1106            //   Preprocess namespaces (true) or don't preprocess (false).  See also
1107            //   the http://xml.org/sax/properties/namespace-sep property.
1108            //
1109            if (feature.equals("namespaces")) {
1110                setNamespaces(state);
1111                return;
1112            }
1113            //
1114            // Not recognized
1115            //
1116        }
1117
1118        //
1119        // Xerces Features
1120        //
1121
1122        else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
1123            String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
1124            //
1125            // http://apache.org/xml/features/validation/schema
1126            //   Lets the user turn Schema validation support on/off.
1127            //
1128            if (feature.equals("validation/schema")) {
1129                setValidationSchema(state);
1130                return;
1131            }
1132            //
1133            // http://apache.org/xml/features/validation/dynamic
1134            //   Allows the parser to validate a document only when it
1135            //   contains a grammar. Validation is turned on/off based
1136            //   on each document instance, automatically.
1137            //
1138            if (feature.equals("validation/dynamic")) {
1139                setValidationDynamic(state);
1140                return;
1141            }
1142            //
1143            // http://apache.org/xml/features/validation/default-attribute-values
1144            //
1145            if (feature.equals("validation/default-attribute-values")) {
1146                // REVISIT
1147                throw new SAXNotSupportedException(featureId);
1148            }
1149            //
1150            // http://apache.org/xml/features/validation/default-attribute-values
1151            //
1152            if (feature.equals("validation/validate-content-models")) {
1153                // REVISIT
1154                throw new SAXNotSupportedException(featureId);
1155            }
1156            //
1157            // http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
1158            //
1159            if (feature.equals("nonvalidating/load-dtd-grammar")) {
1160                setLoadDTDGrammar(state);
1161                return;
1162            }
1163
1164            //
1165            // http://apache.org/xml/features/validation/default-attribute-values
1166            //
1167            if (feature.equals("validation/validate-datatypes")) {
1168                // REVISIT
1169                throw new SAXNotSupportedException(featureId);
1170            }
1171            //
1172            // http://apache.org/xml/features/validation/warn-on-duplicate-attdef
1173            //   Emits an error when an attribute is redefined.
1174            //
1175            if (feature.equals("validation/warn-on-duplicate-attdef")) {
1176                setValidationWarnOnDuplicateAttdef(state);
1177                return;
1178            }
1179            //
1180            // http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
1181            //   Emits an error when an element's content model
1182            //   references an element, by name, that is not declared
1183            //   in the grammar.
1184            //
1185            if (feature.equals("validation/warn-on-undeclared-elemdef")) {
1186                setValidationWarnOnUndeclaredElemdef(state);
1187                return;
1188            }
1189            //
1190            // http://apache.org/xml/features/allow-java-encodings
1191            //   Allows the use of Java encoding names in the XML
1192            //   and TextDecl lines.
1193            //
1194            if (feature.equals("allow-java-encodings")) {
1195                setAllowJavaEncodings(state);
1196                return;
1197            }
1198            //
1199            // http://apache.org/xml/features/continue-after-fatal-error
1200            //   Allows the parser to continue after a fatal error.
1201            //   Normally, a fatal error would stop the parse.
1202            //
1203            if (feature.equals("continue-after-fatal-error")) {
1204                setContinueAfterFatalError(state);
1205                return;
1206            }
1207            //
1208            // Not recognized
1209            //
1210        }
1211
1212        //
1213        // Not recognized
1214        //
1215
1216        throw new SAXNotRecognizedException(featureId);
1217
1218    } // setFeature(String,boolean)
1219
1220    /**
1221     * Query the state of a feature.
1222     *
1223     * Query the current state of any feature in a SAX2 parser.  The
1224     * parser might not recognize the feature.
1225     *
1226     * @param featureId The unique identifier (URI) of the feature
1227     *                  being set.
1228     * @return The current state of the feature.
1229     * @exception org.xml.sax.SAXNotRecognizedException If the
1230     *            requested feature is not known.
1231     * @exception org.xml.sax.SAXException If there is any other
1232     *            problem fulfilling the request.
1233     */
1234    public boolean getFeature(String featureId) 
1235        throws SAXNotRecognizedException, SAXNotSupportedException {
1236
1237        //
1238        // SAX2 Features
1239        //
1240
1241        if (featureId.startsWith(SAX2_FEATURES_PREFIX)) {
1242            String feature = featureId.substring(SAX2_FEATURES_PREFIX.length());
1243            //
1244            // http://xml.org/sax/features/validation
1245            //   Validate (true) or don't validate (false).
1246            //
1247            if (feature.equals("validation")) {
1248                return getValidation();
1249            }
1250            //
1251            // http://xml.org/sax/features/external-general-entities
1252            //   Expand external general entities (true) or don't expand (false).
1253            //
1254            if (feature.equals("external-general-entities")) {
1255                return getExternalGeneralEntities();
1256            }
1257            //
1258            // http://xml.org/sax/features/external-parameter-entities
1259            //   Expand external parameter entities (true) or don't expand (false).
1260            //
1261            if (feature.equals("external-parameter-entities")) {
1262                return getExternalParameterEntities();
1263            }
1264            //
1265            // http://xml.org/sax/features/namespaces
1266            //   Preprocess namespaces (true) or don't preprocess (false).  See also
1267            //   the http://xml.org/sax/properties/namespace-sep property.
1268            //
1269            if (feature.equals("namespaces")) {
1270                return getNamespaces();
1271            }
1272            //
1273            // Not recognized
1274            //
1275        }
1276
1277        //
1278        // Xerces Features
1279        //
1280
1281        else if (featureId.startsWith(XERCES_FEATURES_PREFIX)) {
1282            String feature = featureId.substring(XERCES_FEATURES_PREFIX.length());
1283            //
1284            // http://apache.org/xml/features/validation/schema
1285            //   Lets the user turn Schema validation support on/off.
1286            //
1287            if (feature.equals("validation/schema")) {
1288                return getValidationSchema();
1289            }
1290            //
1291            // http://apache.org/xml/features/validation/dynamic
1292            //   Allows the parser to validate a document only when it
1293            //   contains a grammar. Validation is turned on/off based
1294            //   on each document instance, automatically.
1295            //
1296            if (feature.equals("validation/dynamic")) {
1297                return getValidationDynamic();
1298            }
1299            //
1300            // http://apache.org/xml/features/validation/default-attribute-values
1301            //
1302            if (feature.equals("validation/default-attribute-values")) {
1303                // REVISIT
1304                throw new SAXNotRecognizedException(featureId);
1305            }
1306            //
1307            // http://apache.org/xml/features/validation/validate-content-models
1308            //
1309            if (feature.equals("validation/validate-content-models")) {
1310                // REVISIT
1311                throw new SAXNotRecognizedException(featureId);
1312            }
1313            //
1314            // http://apache.org/xml/features/validation/load-dtd-grammar
1315            //
1316            if (feature.equals("load-dtd-grammar")) {
1317                return getLoadDTDGrammar();
1318            }
1319            //
1320            // http://apache.org/xml/features/validation/validate-datatypes
1321            //
1322            if (feature.equals("validation/validate-datatypes")) {
1323                // REVISIT
1324                throw new SAXNotRecognizedException(featureId);
1325            }
1326            //
1327            // http://apache.org/xml/features/validation/warn-on-duplicate-attdef
1328            //   Emits an error when an attribute is redefined.
1329            //
1330            if (feature.equals("validation/warn-on-duplicate-attdef")) {
1331                return getValidationWarnOnDuplicateAttdef();
1332            }
1333            //
1334            // http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
1335            //   Emits an error when an element's content model
1336            //   references an element, by name, that is not declared
1337            //   in the grammar.
1338            //
1339            if (feature.equals("validation/warn-on-undeclared-elemdef")) {
1340                return getValidationWarnOnUndeclaredElemdef();
1341            }
1342            //
1343            // http://apache.org/xml/features/allow-java-encodings
1344            //   Allows the use of Java encoding names in the XML
1345            //   and TextDecl lines.
1346            //
1347            if (feature.equals("allow-java-encodings")) {
1348                return getAllowJavaEncodings();
1349            }
1350            //
1351            // http://apache.org/xml/features/continue-after-fatal-error
1352            //   Allows the parser to continue after a fatal error.
1353            //   Normally, a fatal error would stop the parse.
1354            //
1355            if (feature.equals("continue-after-fatal-error")) {
1356                return getContinueAfterFatalError();
1357            }
1358            //
1359            // Not recognized
1360            //
1361        }
1362
1363        //
1364        // Not recognized
1365        //
1366
1367        throw new SAXNotRecognizedException(featureId);
1368
1369    } // getFeature(String):boolean
1370
1371    /**
1372     * Set the value of a property.
1373     *
1374     * Set the value of any property in a SAX2 parser.  The parser
1375     * might not recognize the property, and if it does recognize
1376     * it, it might not support the requested value.
1377     *
1378     * @param propertyId The unique identifier (URI) of the property
1379     *                   being set.
1380     * @param Object The value to which the property is being set.
1381     * @exception org.xml.sax.SAXNotRecognizedException If the
1382     *            requested property is not known.
1383     * @exception org.xml.sax.SAXNotSupportedException If the
1384     *            requested property is known, but the requested
1385     *            value is not supported.
1386     * @exception org.xml.sax.SAXException If there is any other
1387     *            problem fulfilling the request.
1388     */
1389    public void setProperty(String propertyId, Object value)
1390        throws SAXNotRecognizedException, SAXNotSupportedException {
1391
1392        //
1393        // SAX2 Properties
1394        //
1395
1396        if (propertyId.startsWith(SAX2_PROPERTIES_PREFIX)) {
1397            String property = propertyId.substring(SAX2_PROPERTIES_PREFIX.length());
1398            //
1399            // http://xml.org/sax/properties/namespace-sep
1400            // Value type: String
1401            // Access: read/write, pre-parse only
1402            //   Set the separator to be used between the URI part of a name and the
1403            //   local part of a name when namespace processing is being performed
1404            //   (see the http://xml.org/sax/features/namespaces feature).  By
1405            //   default, the separator is a single space.  This property may not be
1406            //   set while a parse is in progress (throws a SAXNotSupportedException).
1407            //
1408            /***
1409            if (property.equals("namespace-sep")) {
1410                try {
1411                    setNamespaceSep((String)value);
1412                }
1413                catch (ClassCastException e) {
1414                    throw new SAXNotSupportedException(propertyId);
1415                }
1416                return;
1417            }
1418            /***/
1419            
1420            //
1421            // http://xml.org/sax/properties/xml-string
1422            // Value type: String
1423            // Access: read-only
1424            //   Get the literal string of characters associated with the current
1425            //   event.  If the parser recognises and supports this property but is
1426            //   not currently parsing text, it should return null (this is a good
1427            //   way to check for availability before the parse begins).
1428            //
1429            if (property.equals("xml-string")) {
1430                // REVISIT - we should probably ask xml-dev for a precise definition
1431                // of what this is actually supposed to return, and in exactly which
1432                // circumstances.
1433                throw new SAXNotSupportedException(propertyId);
1434            }
1435            //
1436            // Not recognized
1437            //
1438        }
1439
1440        //
1441        // Xerces Properties
1442        //
1443
1444        /*
1445        else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
1446            //
1447            // No properties defined yet that are common to all parsers.
1448            //
1449        }
1450        */
1451
1452        //
1453        // Not recognized
1454        //
1455
1456        throw new SAXNotRecognizedException(propertyId);
1457
1458    } // setProperty(String,Object)
1459
1460    /**
1461     * Query the value of a property.
1462     *
1463     * Return the current value of a property in a SAX2 parser.
1464     * The parser might not recognize the property.
1465     *
1466     * @param propertyId The unique identifier (URI) of the property
1467     *                   being set.
1468     * @return The current value of the property.
1469     * @exception org.xml.sax.SAXNotRecognizedException If the
1470     *            requested property is not known.
1471     * @exception org.xml.sax.SAXException If there is any other
1472     *            problem fulfilling the request.
1473     * @see org.xml.sax.XMLReader#getProperty
1474     */
1475    public Object getProperty(String propertyId) 
1476        throws SAXNotRecognizedException, SAXNotSupportedException {
1477
1478        //
1479        // SAX2 Properties
1480        //
1481
1482        if (propertyId.startsWith(SAX2_PROPERTIES_PREFIX)) {
1483            String property = propertyId.substring(SAX2_PROPERTIES_PREFIX.length());
1484            //
1485            // http://xml.org/sax/properties/namespace-sep
1486            // Value type: String
1487            // Access: read/write, pre-parse only
1488            //   Set the separator to be used between the URI part of a name and the
1489            //   local part of a name when namespace processing is being performed
1490            //   (see the http://xml.org/sax/features/namespaces feature).  By
1491            //   default, the separator is a single space.  This property may not be
1492            //   set while a parse is in progress (throws a SAXNotSupportedException).
1493            //
1494            /***
1495            if (property.equals("namespace-sep")) {
1496                return getNamespaceSep();
1497            }
1498            /***/
1499            //
1500            // http://xml.org/sax/properties/xml-string
1501            // Value type: String
1502            // Access: read-only
1503            //   Get the literal string of characters associated with the current
1504            //   event.  If the parser recognises and supports this property but is
1505            //   not currently parsing text, it should return null (this is a good
1506            //   way to check for availability before the parse begins).
1507            //
1508            if (property.equals("xml-string")) {
1509                return getXMLString();
1510            }
1511            //
1512            // Not recognized
1513            //
1514        }
1515
1516        //
1517        // Xerces Properties
1518        //
1519
1520        /*
1521        else if (propertyId.startsWith(XERCES_PROPERTIES_PREFIX)) {
1522            //
1523            // No properties defined yet that are common to all parsers.
1524            //
1525        }
1526        */
1527
1528        //
1529        // Not recognized
1530        //
1531
1532        throw new SAXNotRecognizedException(propertyId);
1533
1534    } // getProperty(String):Object
1535
1536}