KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > apache > xerces > framework > XMLParser


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.enhydra.apache.xerces.framework;
59
60 import java.io.IOException JavaDoc;
61 import java.io.InputStream JavaDoc;
62 import java.io.Reader JavaDoc;
63 import java.util.Locale JavaDoc;
64
65 import org.enhydra.apache.xerces.readers.DefaultEntityHandler;
66 import org.enhydra.apache.xerces.readers.XMLDeclRecognizer;
67 import org.enhydra.apache.xerces.readers.XMLEntityReaderFactory;
68 import org.enhydra.apache.xerces.utils.ChunkyCharArray;
69 import org.enhydra.apache.xerces.utils.ImplementationMessages;
70 import org.enhydra.apache.xerces.utils.StringPool;
71 import org.enhydra.apache.xerces.utils.XMLMessageProvider;
72 import org.enhydra.apache.xerces.utils.XMLMessages;
73 import org.enhydra.apache.xerces.validators.common.GrammarResolver;
74 import org.enhydra.apache.xerces.validators.common.GrammarResolverImpl;
75 import org.enhydra.apache.xerces.validators.common.XMLValidator;
76 import org.enhydra.apache.xerces.validators.datatype.DatatypeMessageProvider;
77 import org.enhydra.apache.xerces.validators.schema.SchemaMessageProvider;
78 import org.xml.sax.EntityResolver JavaDoc;
79 import org.xml.sax.ErrorHandler JavaDoc;
80 import org.xml.sax.InputSource JavaDoc;
81 import org.xml.sax.Locator JavaDoc;
82 import org.xml.sax.SAXException JavaDoc;
83 import org.xml.sax.SAXNotRecognizedException JavaDoc;
84 import org.xml.sax.SAXNotSupportedException JavaDoc;
85 import org.xml.sax.SAXParseException JavaDoc;
86
87 /**
88  * This is the base class of all standard parsers.
89  *
90  * @version $Id: XMLParser.java,v 1.2 2005/01/26 08:28:44 jkjome Exp $
91  */

92 public abstract class XMLParser
93     implements XMLErrorReporter, XMLDocumentHandler.DTDHandler {
94
95     //
96
// Constants
97
//
98

99     // protected
100

101     /** SAX2 features prefix (http://xml.org/sax/features/). */
102     protected static final String JavaDoc SAX2_FEATURES_PREFIX = "http://xml.org/sax/features/";
103
104     /** SAX2 properties prefix (http://xml.org/sax/properties/). */
105     protected static final String JavaDoc SAX2_PROPERTIES_PREFIX = "http://xml.org/sax/properties/";
106
107     /** Xerces features prefix (http://apache.org/xml/features/). */
108     protected static final String JavaDoc XERCES_FEATURES_PREFIX = "http://apache.org/xml/features/";
109
110     /** Xerces properties prefix (http://apache.org/xml/properties/). */
111     protected static final String JavaDoc XERCES_PROPERTIES_PREFIX = "http://apache.org/xml/properties/";
112
113     // private
114

115     /** Features recognized by this parser. */
116     private static final String JavaDoc RECOGNIZED_FEATURES[] = {
117         // SAX2 core
118
"http://xml.org/sax/features/validation",
119         "http://xml.org/sax/features/external-general-entities",
120         "http://xml.org/sax/features/external-parameter-entities",
121         "http://xml.org/sax/features/namespaces",
122         // Xerces
123
"http://apache.org/xml/features/validation/schema",
124         // "http://apache.org/xml/features/schema/expose-normalized-values",
125
"http://apache.org/xml/features/validation/schema-full-checking",
126         "http://apache.org/xml/features/validation/dynamic",
127         "http://apache.org/xml/features/validation/default-attribute-values",
128         
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         "http://apache.org/xml/features/nonvalidating/load-external-dtd"
137     };
138
139     /** Properties recognized by this parser. */
140     private static final String JavaDoc RECOGNIZED_PROPERTIES[] = {
141         // SAX2 core
142
"http://xml.org/sax/properties/xml-string",
143         // Xerces
144
"http://apache.org/xml/properties/schema/external-schemaLocation",
145         "http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation"
146     };
147
148     // debugging
149

150     /** Set to true and recompile to print exception stack trace. */
151     private static final boolean PRINT_EXCEPTION_STACK_TRACE = false;
152
153     //
154
// Data
155
//
156

157     protected GrammarResolver fGrammarResolver = null;
158
159     // state
160

161     protected boolean fParseInProgress = false;
162     private boolean fNeedReset = false;
163
164     // features
165

166     /** Continue after fatal error. */
167     private boolean fContinueAfterFatalError = false;
168
169     // properties
170

171     /** Error handler. */
172     private ErrorHandler JavaDoc fErrorHandler = null;
173
174     // other
175

176     private Locale JavaDoc fLocale = null;
177
178     // error information
179

180     private static XMLMessageProvider fgXMLMessages = new XMLMessages();
181     private static XMLMessageProvider fgImplementationMessages = new ImplementationMessages();
182     private static XMLMessageProvider fgSchemaMessages = new SchemaMessageProvider();
183     private static XMLMessageProvider fgDatatypeMessages= new DatatypeMessageProvider();
184
185     //
186
//
187
//
188
protected StringPool fStringPool = null;
189     protected XMLErrorReporter fErrorReporter = null;
190     protected DefaultEntityHandler fEntityHandler = null;
191     protected XMLDocumentScanner fScanner = null;
192     protected XMLValidator fValidator = null;
193
194     //
195
// Constructors
196
//
197

198     /**
199      * Constructor
200      */

201     protected XMLParser() {
202         this(new StringPool());
203     }
204
205     protected XMLParser(StringPool stringPool) {
206         fStringPool = stringPool;
207         fErrorReporter = this;
208         fEntityHandler = new DefaultEntityHandler(fStringPool, fErrorReporter);
209         fScanner = new XMLDocumentScanner(fStringPool, fErrorReporter, fEntityHandler, new ChunkyCharArray(fStringPool));
210         fValidator = new XMLValidator(fStringPool, fErrorReporter, fEntityHandler, fScanner);
211         fGrammarResolver = new GrammarResolverImpl();
212         fScanner.setGrammarResolver(fGrammarResolver);
213         fValidator.setGrammarResolver(fGrammarResolver);
214         try {
215             //JR-defect 48 fix - turn on Namespaces
216
setNamespaces(true);
217         }
218         catch (Exception JavaDoc e) {
219             // ignore
220
}
221     }
222
223     /**
224      * Set char data processing preference and handlers.
225      */

226     protected void initHandlers(boolean sendCharDataAsCharArray,
227                                 XMLDocumentHandler docHandler,
228                                 XMLDocumentHandler.DTDHandler dtdHandler)
229     {
230         fValidator.initHandlers(sendCharDataAsCharArray, docHandler, dtdHandler);
231         fScanner.setDTDHandler(this);
232     }
233
234     //
235
// Public methods
236
//
237

238     // features and properties
239

240     /**
241      * Returns a list of features that this parser recognizes.
242      * This method will never return null; if no features are
243      * recognized, this method will return a zero length array.
244      *
245      * @see #isFeatureRecognized
246      * @see #setFeature
247      * @see #getFeature
248      */

249     public String JavaDoc[] getFeaturesRecognized() {
250         return RECOGNIZED_FEATURES;
251     }
252
253     /**
254      * Returns true if the specified feature is recognized.
255      *
256      * @see #getFeaturesRecognized
257      * @see #setFeature
258      * @see #getFeature
259      */

260     public boolean isFeatureRecognized(String JavaDoc featureId) {
261         String JavaDoc[] recognizedFeatures = getFeaturesRecognized();
262         for (int i = 0; i < recognizedFeatures.length; i++) {
263             if (featureId.equals(recognizedFeatures[i]))
264                 return true;
265         }
266         return false;
267     }
268
269     /**
270      * Returns a list of properties that this parser recognizes.
271      * This method will never return null; if no properties are
272      * recognized, this method will return a zero length array.
273      *
274      * @see #isPropertyRecognized
275      * @see #setProperty
276      * @see #getProperty
277      */

278     public String JavaDoc[] getPropertiesRecognized() {
279         return RECOGNIZED_PROPERTIES;
280     }
281
282     /**
283      * Returns true if the specified property is recognized.
284      *
285      * @see #getPropertiesRecognized
286      * @see #setProperty
287      * @see #getProperty
288      */

289     public boolean isPropertyRecognized(String JavaDoc propertyId) {
290         String JavaDoc[] recognizedProperties = getPropertiesRecognized();
291         for (int i = 0; i < recognizedProperties.length; i++) {
292             if (propertyId.equals(recognizedProperties[i]))
293                 return true;
294         }
295         return false;
296     }
297
298     // initialization
299

300     /**
301      * Setup for application-driven parsing.
302      *
303      * @param source the input source to be parsed.
304      * @see #parseSome
305      */

306     public boolean parseSomeSetup(InputSource JavaDoc source) throws Exception JavaDoc {
307         if (fNeedReset)
308             resetOrCopy();
309         fParseInProgress = true;
310         fNeedReset = true;
311         return fEntityHandler.startReadingFromDocument(source);
312     }
313
314     /**
315      * Application-driven parsing.
316      *
317      * @see #parseSomeSetup
318      */

319     public boolean parseSome() throws Exception JavaDoc {
320         if (!fScanner.parseSome(false)) {
321             fParseInProgress = false;
322             return false;
323         }
324         return true;
325     }
326
327     // resetting
328

329     /** Reset parser instance so that it can be reused. */
330     public void reset() throws Exception JavaDoc {
331         fGrammarResolver.clearGrammarResolver();
332         fStringPool.reset();
333         fEntityHandler.reset(fStringPool);
334         fScanner.reset(fStringPool, new ChunkyCharArray(fStringPool));
335         fValidator.reset(fStringPool);
336         fNeedReset = false;
337     }
338
339     // properties (the normal kind)
340

341     /**
342      * return the locator being used by the parser
343      *
344      * @return the parser's active locator
345      */

346     public final Locator JavaDoc getLocator() {
347         return fEntityHandler;
348     }
349
350
351     /**
352      * return the locale
353      *
354      * @return the locale
355      */

356     public final Locale JavaDoc getfLocale() {
357         return fLocale;
358     }
359
360     /**
361      * return the XML Messages object
362      *
363      * @return the parser's messages object
364      */

365     public final XMLMessageProvider getfgXMLMessages() {
366         return fgXMLMessages;
367     }
368
369     /**
370      * return the Implementation Messages object
371      *
372      * @return the parser's implementation messages
373      */

374     public final XMLMessageProvider getfgImplementationMessages() {
375         return fgImplementationMessages;
376     }
377
378     /**
379      * return the Schema Messages object
380      *
381      * @return the parser's schema messages
382      */

383     public final XMLMessageProvider getfgSchemaMessages() {
384         return fgSchemaMessages;
385     }
386
387     /**
388      * return the Datatypes Messages object
389      *
390      * @return the parser's datatypes messages
391      */

392     public final XMLMessageProvider getfgDatatypeMessages() {
393         return fgDatatypeMessages;
394     }
395
396     /**
397      * Set the reader factory.
398      */

399     public void setReaderFactory(XMLEntityReaderFactory readerFactory) {
400         fEntityHandler.setReaderFactory(readerFactory);
401     }
402
403     /**
404      * Adds a recognizer.
405      *
406      * @param recognizer The XML recognizer to add.
407      */

408     public void addRecognizer(XMLDeclRecognizer recognizer) {
409         fEntityHandler.addRecognizer(recognizer);
410     }
411
412     //
413
// Protected methods
414
//
415

416     // SAX2 core features
417

418     /**
419      * Sets whether the parser validates.
420      * <p>
421      * This method is the equivalent to the feature:
422      * <pre>
423      * http://xml.org/sax/features/validation
424      * </pre>
425      *
426      * @param validate True to validate; false to not validate.
427      *
428      * @see #getValidation
429      * @see #setFeature
430      */

431     protected void setValidation(boolean validate)
432         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
433         if (fParseInProgress) {
434             throw new SAXNotSupportedException JavaDoc("PAR004 Cannot setFeature(http://xml.org/sax/features/validation): parse is in progress.\n"+
435                                                "http://xml.org/sax/features/validation");
436         }
437         try {
438             // REVISIT: [Q] Should the scanner tell the validator that
439
// validation is on? -Ac
440
fScanner.setValidationEnabled(validate);
441             fValidator.setValidationEnabled(validate);
442         }
443         catch (Exception JavaDoc ex) {
444             throw new SAXNotSupportedException JavaDoc(ex.getMessage());
445         }
446     }
447
448     /**
449      * Returns true if validation is turned on.
450      *
451      * @see #setValidation
452      */

453     protected boolean getValidation()
454         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
455         return fValidator.getValidationEnabled();
456     }
457
458     /**
459      * <b>Note: Currently, this parser always expands external general
460      * entities.</b> Setting this feature to false will throw a
461      * SAXNotSupportedException.
462      * <p>
463      * Sets whether external general entities are expanded.
464      * <p>
465      * This method is the equivalent to the feature:
466      * <pre>
467      * http://xml.org/sax/features/external-general-entities
468      * </pre>
469      *
470      * @param expand True to expand external general entities; false
471      * to not expand.
472      *
473      * @see #getExternalGeneralEntities
474      * @see #setFeature
475      */

476     protected void setExternalGeneralEntities(boolean expand)
477         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
478         if (fParseInProgress) {
479             throw new SAXNotSupportedException JavaDoc("PAR004 Cannot setFeature(http://xml.org/sax/features/external-general-entities): parse is in progress.\n"+
480                                                "http://xml.org/sax/features/external-general-entities");
481         }
482         if (!expand) {
483             throw new SAXNotSupportedException JavaDoc("http://xml.org/sax/features/external-general-entities");
484         }
485     }
486
487     /**
488      * <b>Note: This feature is always true.</b>
489      * <p>
490      * Returns true if external general entities are expanded.
491      *
492      * @see #setExternalGeneralEntities
493      */

494     protected boolean getExternalGeneralEntities()
495         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
496         return true;
497     }
498
499     /**
500      * <b>Note: Currently, this parser always expands external parameter
501      * entities.</b> Setting this feature to false will throw a
502      * SAXNotSupportedException.
503      * <p>
504      * Sets whether external parameter entities are expanded.
505      * <p>
506      * This method is the equivalent to the feature:
507      * <pre>
508      * http://xml.org/sax/features/external-parameter-entities
509      * </pre>
510      *
511      * @param expand True to expand external parameter entities; false
512      * to not expand.
513      *
514      * @see #getExternalParameterEntities
515      * @see #setFeature
516      */

517     protected void setExternalParameterEntities(boolean expand)
518         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
519         if (fParseInProgress) {
520             throw new SAXNotSupportedException JavaDoc("PAR004 Cannot setFeature(http://xml.org/sax/features/external-general-entities): parse is in progress.\n"+
521                                                "http://xml.org/sax/features/external-general-entities");
522         }
523         if (!expand) {
524             throw new SAXNotSupportedException JavaDoc("http://xml.org/sax/features/external-parameter-entities");
525         }
526     }
527
528     /**
529      * <b>Note: This feature is always true.</b>
530      * <p>
531      * Returns true if external parameter entities are expanded.
532      *
533      * @see #setExternalParameterEntities
534      */

535     protected boolean getExternalParameterEntities()
536         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
537         return true;
538     }
539
540     /**
541      * Sets whether the parser preprocesses namespaces.
542      * <p>
543      * This method is the equivalent to the feature:
544      * <pre>
545      * http://xml.org/sax/features/namespaces
546      * <pre>
547      *
548      * @param process True to process namespaces; false to not process.
549      *
550      * @see #getNamespaces
551      * @see #setFeature
552      */

553     protected void setNamespaces(boolean process)
554         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
555         if (fParseInProgress) {
556             throw new SAXNotSupportedException JavaDoc("PAR004 Cannot setFeature(http://xml.org/sax/features/namespaces): parse is in progress.\n"+
557                                                "http://xml.org/sax/features/namespaces");
558         }
559         fScanner.setNamespacesEnabled(process);
560         // REVISIT: [Q] Should the scanner tell the validator that namespace
561
// processing is on? -Ac
562
fValidator.setNamespacesEnabled(process);
563     }
564
565     /**
566      * Returns true if the parser preprocesses namespaces.
567      *
568      * @see #setNamespaces
569      */

570     protected boolean getNamespaces()
571         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
572         return fValidator.getNamespacesEnabled();
573     }
574
575     // Xerces features
576

577     /**
578      * Allows the user to turn Schema support on/off.
579      * <p>
580      * This method is equivalent to the feature:
581      * <pre>
582      * http://apache.org/xml/features/validation/schema
583      * </pre>
584      *
585      * @param schema True to turn on Schema support; false to turn it off.
586      *
587      * @see #getValidationSchema
588      * @see #setFeature
589      */

590     protected void setValidationSchema(boolean schema)
591         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
592         if (fParseInProgress) {
593             // REVISIT: Localize message
594
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/features/validation/schema: parse is in progress");
595         }
596         fValidator.setSchemaValidationEnabled(schema);
597     }
598
599     /**
600      * Returns true if Schema support is turned on.
601      *
602      * @see #setValidationSchema
603      */

604     protected boolean getValidationSchema()
605         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
606         return fValidator.getSchemaValidationEnabled();
607     }
608
609     /**
610      * Allows the user to turn full Schema constraint checking on/off.
611      * Only takes effect if Schema validation is enabled.
612      * If this feature is off, partial constraint checking is done.
613      * <p>
614      * This method is equivalent to the feature:
615      * <pre>
616      * http://apache.org/xml/features/validation/schema-full-checking
617      * </pre>
618      *
619      * @param schemaFullChecking True to turn on full schema constraint checking.
620      *
621      * @see #getValidationSchemaFullChecking
622      * @see #setFeature
623      */

624     protected void setValidationSchemaFullChecking(boolean schemaFullChecking)
625         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
626         if (fParseInProgress) {
627             // REVISIT: Localize message
628
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/features/validation/schema-full-checking: parse is in progress");
629         }
630         fValidator.setSchemaFullCheckingEnabled(schemaFullChecking);
631     }
632
633
634     /**
635      * Normalization of element content is controlled by this feature.
636      * If this feature is set to true, DOM and SAX APIs will expose element content
637      * that is normalized according to XML Schema REC.
638      * Otherwise, element content will be exposed as required by the infoset.
639      *
640      * @param normalize
641      */

642     protected void setNormalizeContents(boolean normalize) {
643         fValidator.setNormalizeContents(normalize);
644     }
645     protected boolean getNormalizeContents() {
646         return fValidator.getNormalizeConents();
647     }
648
649     /**
650      * Allows the user to set a list of external XML Schemas (ex."http://example.com schema.xsd")
651      * to be used by the parser.
652      * If two schemas with the same targetNamespace appear in both
653      * the list and a document, the one from the list will be picked up.
654      * See XML Schema REC: http://www.w3.org/TR/xmlschema-1/#schema-loc
655      * <P>
656      * This method is equivalent to the property:
657      * <PRE>http://apache.org/xml/properties/schema/external-schemaLocation</PRE>
658      *
659      * @param value The list of schemas.
660      * @exception SAXNotRecognizedException
661      * @exception SAXNotSupportedException
662      */

663     protected void setExternalSchemaLocation(Object JavaDoc value)
664         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
665         if (fParseInProgress) {
666             // REVISIT: Localize message
667
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/properties/validation/schema/external-schemaLocation: parse is in progress");
668         }
669         fValidator.setExternalSchemas(value);
670     }
671
672     /**
673      * Allows the user to set external XML Schema with no target Namespace.
674      * This value overwrites the value on the _noNamespaceSchemaLocation_.
675      * See XML Schema REC: http://www.w3.org/TR/xmlschema-1/#schema-loc
676      * <P>
677      * This method is equivalent to the property:
678      * <PRE>http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation</PRE>
679      *
680      * @param value An XML Schema file name
681      * @exception SAXNotRecognizedException
682      * @exception SAXNotSupportedException
683      */

684     protected void setExternalNoNamespaceSchemaLocation(Object JavaDoc value)
685         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
686         if (fParseInProgress) {
687             // REVISIT: Localize message
688
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation: parse is in progress");
689         }
690         fValidator.setExternalNoNamespaceSchema(value);
691     }
692
693     /**
694      * Returns true if Schema support is turned on.
695      *
696      * @see #setValidationSchemaFullChecking
697      */

698     protected boolean getValidationSchemaFullChecking()
699         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
700         return fValidator.getSchemaFullCheckingEnabled();
701     }
702
703
704     /**
705      * Allows the parser to validate a document only when it contains a
706      * grammar. Validation is turned on/off based on each document
707      * instance, automatically.
708      * <p>
709      * This method is the equivalent to the feature:
710      * <pre>
711      * http://apache.org/xml/features/validation/dynamic
712      * </pre>
713      *
714      * @param dynamic True to dynamically validate documents; false to
715      * validate based on the validation feature.
716      *
717      * @see #getValidationDynamic
718      * @see #setFeature
719      */

720     protected void setValidationDynamic(boolean dynamic)
721         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
722         if (fParseInProgress) {
723             // REVISIT: Localize message
724
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/features/validation/dynamic: parse is in progress");
725         }
726         try {
727             fValidator.setDynamicValidationEnabled(dynamic);
728         }
729         catch (Exception JavaDoc ex) {
730             throw new SAXNotSupportedException JavaDoc(ex.getMessage());
731         }
732     }
733
734     /**
735      * Returns true if validation is based on whether a document
736      * contains a grammar.
737      *
738      * @see #setValidationDynamic
739      */

740     protected boolean getValidationDynamic()
741         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
742         return fValidator.getDynamicValidationEnabled();
743     }
744
745     /**
746      *
747      */

748     protected void setNormalizeAttributeValues(boolean normalize) {
749         fValidator.setNormalizeAttributeValues(normalize);
750     }
751
752     /**
753      * Allows the parser to have the choice to load DTD grammar when
754      * validation is off.
755      * <p>
756      * This method is the equivalent to the feature:
757      * <pre>
758      * http://apache.org/xml/features/nonvalidating/load-dtd-grammar
759      * </pre>
760      *
761      * @param loadDTDGrammar True to turn on the feature; false to
762      * turn off the feature.
763      *
764      * @see #getLoadDTDGrammar
765      * @see #setFeature
766      */

767     protected void setLoadDTDGrammar(boolean loadDTDGrammar)
768         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
769         if (fParseInProgress) {
770             // REVISIT: Localize message
771
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/features/nonvalidating/load-dtd-grammar: parse is in progress");
772         }
773         try {
774             fValidator.setLoadDTDGrammar(loadDTDGrammar);
775         }
776         catch (Exception JavaDoc ex) {
777             throw new SAXNotSupportedException JavaDoc(ex.getMessage());
778         }
779     }
780
781     /**
782      * Returns true if load DTD grammar is turned on in the XMLValiator.
783      *
784      * @see #setLoadDTDGrammar
785      */

786     protected boolean getLoadDTDGrammar()
787         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
788         return fValidator.getLoadDTDGrammar();
789     }
790
791     /**
792      * Allows the parser to have the choice to load the external DTD when
793      * validation is off.
794      * <p>
795      * This method is the equivalent to the feature:
796      * <pre>
797      * http://apache.org/xml/features/nonvalidating/load-external-dtd
798      * </pre>
799      *
800      * @param loadExternalDTD True to turn on the feature; false to
801      * turn off the feature.
802      *
803      * @see #getLoadExternalDTD
804      * @see #setFeature
805      */

806     protected void setLoadExternalDTD(boolean loadExternalDTD)
807         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
808         if (fParseInProgress) {
809             // REVISIT: Localize message
810
throw new SAXNotSupportedException JavaDoc("http://apache.org/xml/features/nonvalidating/load-external-dtd: parse is in progress");
811         }
812         try {
813             fScanner.setLoadExternalDTD(loadExternalDTD);
814         }
815         catch (Exception JavaDoc ex) {
816             throw new SAXNotSupportedException JavaDoc(ex.getMessage());
817         }
818     }
819
820     /**
821      * Returns true if loading of the external DTD is on.
822      *
823      * @see #setLoadExternalDTD
824      */

825     protected boolean getLoadExternalDTD()
826         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
827         return fScanner.getLoadExternalDTD();
828     }
829
830     /**
831      * Sets whether an error is emitted when an attribute is redefined
832      * in the grammar.
833      * <p>
834      * This method is the equivalent to the feature:
835      * <pre>
836      * http://apache.org/xml/features/validation/warn-on-duplicate-attdef
837      * </pre>
838      *
839      * @param warn True to warn; false to not warn.
840      *
841      * @see #getValidationWarnOnDuplicateAttdef
842      * @see #setFeature
843      */

844     protected void setValidationWarnOnDuplicateAttdef(boolean warn)
845         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
846         fValidator.setWarningOnDuplicateAttDef(warn);
847     }
848
849     /**
850      * Returns true if an error is emitted when an attribute is redefined
851      * in the grammar.
852      *
853      * @see #setValidationWarnOnDuplicateAttdef
854      */

855     protected boolean getValidationWarnOnDuplicateAttdef()
856         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
857         return fValidator.getWarningOnDuplicateAttDef();
858     }
859
860     /**
861      * Sets whether the parser emits an error when an element's content
862      * model references an element by name that is not declared in the
863      * grammar.
864      * <p>
865      * This method is the equivalent to the feature:
866      * <pre>
867      * http://apache.org/xml/features/validation/warn-on-undeclared-elemdef
868      * </pre>
869      *
870      * @param warn True to warn; false to not warn.
871      *
872      * @see #getValidationWarnOnUndeclaredElemdef
873      * @see #setFeature
874      */

875     protected void setValidationWarnOnUndeclaredElemdef(boolean warn)
876         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
877         fValidator.setWarningOnUndeclaredElements(warn);
878     }
879
880     /**
881      * Returns true if the parser emits an error when an undeclared
882      * element is referenced in the grammar.
883      *
884      * @see #setValidationWarnOnUndeclaredElemdef
885      */

886     protected boolean getVa