KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > impl > xs > opti > SchemaParsingConfig


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.apache.xerces.impl.xs.opti;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Locale JavaDoc;
21
22 import org.apache.xerces.impl.Constants;
23 import org.apache.xerces.impl.XMLDTDScannerImpl;
24 import org.apache.xerces.impl.XMLEntityManager;
25 import org.apache.xerces.impl.XMLErrorReporter;
26 import org.apache.xerces.impl.XMLNSDocumentScannerImpl;
27 import org.apache.xerces.impl.dv.DTDDVFactory;
28 import org.apache.xerces.impl.msg.XMLMessageFormatter;
29 import org.apache.xerces.impl.validation.ValidationManager;
30 import org.apache.xerces.impl.xs.XSMessageFormatter;
31 import org.apache.xerces.parsers.BasicParserConfiguration;
32 import org.apache.xerces.util.SymbolTable;
33 import org.apache.xerces.xni.XMLLocator;
34 import org.apache.xerces.xni.XNIException;
35 import org.apache.xerces.xni.grammars.XMLGrammarPool;
36 import org.apache.xerces.xni.parser.XMLComponent;
37 import org.apache.xerces.xni.parser.XMLComponentManager;
38 import org.apache.xerces.xni.parser.XMLConfigurationException;
39 import org.apache.xerces.xni.parser.XMLDTDScanner;
40 import org.apache.xerces.xni.parser.XMLDocumentScanner;
41 import org.apache.xerces.xni.parser.XMLInputSource;
42 import org.apache.xerces.xni.parser.XMLPullParserConfiguration;
43 import org.w3c.dom.Document JavaDoc;
44
45
46 /**
47  * @xerces.internal
48  *
49  * @author Rahul Srivastava, Sun Microsystems Inc.
50  *
51  * @version $Id: SchemaParsingConfig.java,v 1.9 2004/12/16 16:45:20 ankitp Exp $
52  */

53 public class SchemaParsingConfig extends BasicParserConfiguration
54 implements XMLPullParserConfiguration {
55     
56     //
57
// Constants
58
//
59

60     // feature identifiers
61

62     /** Feature identifier: warn on duplicate attribute definition. */
63     protected static final String JavaDoc WARN_ON_DUPLICATE_ATTDEF =
64         Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ATTDEF_FEATURE;
65     
66     /** Feature identifier: warn on duplicate entity definition. */
67     // protected static final String WARN_ON_DUPLICATE_ENTITYDEF = Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_DUPLICATE_ENTITYDEF_FEATURE;
68

69     /** Feature identifier: warn on undeclared element definition. */
70     protected static final String JavaDoc WARN_ON_UNDECLARED_ELEMDEF =
71         Constants.XERCES_FEATURE_PREFIX + Constants.WARN_ON_UNDECLARED_ELEMDEF_FEATURE;
72     
73     /** Feature identifier: allow Java encodings. */
74     protected static final String JavaDoc ALLOW_JAVA_ENCODINGS =
75         Constants.XERCES_FEATURE_PREFIX + Constants.ALLOW_JAVA_ENCODINGS_FEATURE;
76     
77     /** Feature identifier: continue after fatal error. */
78     protected static final String JavaDoc CONTINUE_AFTER_FATAL_ERROR =
79         Constants.XERCES_FEATURE_PREFIX + Constants.CONTINUE_AFTER_FATAL_ERROR_FEATURE;
80     
81     /** Feature identifier: load external DTD. */
82     protected static final String JavaDoc LOAD_EXTERNAL_DTD =
83         Constants.XERCES_FEATURE_PREFIX + Constants.LOAD_EXTERNAL_DTD_FEATURE;
84     
85     /** Feature identifier: notify built-in refereces. */
86     protected static final String JavaDoc NOTIFY_BUILTIN_REFS =
87         Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_BUILTIN_REFS_FEATURE;
88     
89     /** Feature identifier: notify character refereces. */
90     protected static final String JavaDoc NOTIFY_CHAR_REFS =
91         Constants.XERCES_FEATURE_PREFIX + Constants.NOTIFY_CHAR_REFS_FEATURE;
92     
93     
94     /** Feature identifier: expose schema normalized value */
95     protected static final String JavaDoc NORMALIZE_DATA =
96         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE;
97     
98     
99     /** Feature identifier: send element default value via characters() */
100     protected static final String JavaDoc SCHEMA_ELEMENT_DEFAULT =
101         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT;
102     
103     /** Feature identifier: generate synthetic annotations. */
104     protected static final String JavaDoc GENERATE_SYNTHETIC_ANNOTATION =
105         Constants.XERCES_FEATURE_PREFIX + Constants.GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE;
106     
107     
108     // property identifiers
109

110     /** Property identifier: error reporter. */
111     protected static final String JavaDoc ERROR_REPORTER =
112         Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_REPORTER_PROPERTY;
113     
114     /** Property identifier: entity manager. */
115     protected static final String JavaDoc ENTITY_MANAGER =
116         Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_MANAGER_PROPERTY;
117     
118     /** Property identifier document scanner: */
119     protected static final String JavaDoc DOCUMENT_SCANNER =
120         Constants.XERCES_PROPERTY_PREFIX + Constants.DOCUMENT_SCANNER_PROPERTY;
121     
122     /** Property identifier: DTD scanner. */
123     protected static final String JavaDoc DTD_SCANNER =
124         Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_SCANNER_PROPERTY;
125     
126     /** Property identifier: grammar pool. */
127     protected static final String JavaDoc XMLGRAMMAR_POOL =
128         Constants.XERCES_PROPERTY_PREFIX + Constants.XMLGRAMMAR_POOL_PROPERTY;
129     
130     /** Property identifier: DTD validator. */
131     protected static final String JavaDoc DTD_VALIDATOR =
132         Constants.XERCES_PROPERTY_PREFIX + Constants.DTD_VALIDATOR_PROPERTY;
133     
134     /** Property identifier: namespace binder. */
135     protected static final String JavaDoc NAMESPACE_BINDER =
136         Constants.XERCES_PROPERTY_PREFIX + Constants.NAMESPACE_BINDER_PROPERTY;
137     
138     /** Property identifier: datatype validator factory. */
139     protected static final String JavaDoc DATATYPE_VALIDATOR_FACTORY =
140         Constants.XERCES_PROPERTY_PREFIX + Constants.DATATYPE_VALIDATOR_FACTORY_PROPERTY;
141     
142     protected static final String JavaDoc VALIDATION_MANAGER =
143         Constants.XERCES_PROPERTY_PREFIX + Constants.VALIDATION_MANAGER_PROPERTY;
144     
145     /** Property identifier: XML Schema validator. */
146     protected static final String JavaDoc SCHEMA_VALIDATOR =
147         Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY;
148     
149     
150     // debugging
151

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

159     // components (non-configurable)
160

161     /** Grammar pool. */
162     protected XMLGrammarPool fGrammarPool;
163     
164     /** Datatype validator factory. */
165     protected DTDDVFactory fDatatypeValidatorFactory;
166     
167     // components (configurable)
168

169     /** Error reporter. */
170     protected XMLErrorReporter fErrorReporter;
171     
172     /** Entity manager. */
173     protected XMLEntityManager fEntityManager;
174     
175     /** Document scanner. */
176     protected XMLDocumentScanner fScanner;
177     
178     /** Input Source */
179     protected XMLInputSource fInputSource;
180     
181     /** DTD scanner. */
182     protected XMLDTDScanner fDTDScanner;
183     
184     
185     protected SchemaDOMParser fSchemaDOMParser;
186     
187     protected ValidationManager fValidationManager;
188     // state
189

190     /** Locator */
191     protected XMLLocator fLocator;
192     
193     /**
194      * True if a parse is in progress. This state is needed because
195      * some features/properties cannot be set while parsing (e.g.
196      * validation and namespaces).
197      */

198     protected boolean fParseInProgress = false;
199     
200     //
201
// Constructors
202
//
203

204     /** Default constructor. */
205     public SchemaParsingConfig() {
206         this(null, null, null);
207     } // <init>()
208

209     /**
210      * Constructs a parser configuration using the specified symbol table.
211      *
212      * @param symbolTable The symbol table to use.
213      */

214     public SchemaParsingConfig(SymbolTable symbolTable) {
215         this(symbolTable, null, null);
216     } // <init>(SymbolTable)
217

218     /**
219      * Constructs a parser configuration using the specified symbol table and
220      * grammar pool.
221      * <p>
222      * <strong>REVISIT:</strong>
223      * Grammar pool will be updated when the new validation engine is
224      * implemented.
225      *
226      * @param symbolTable The symbol table to use.
227      * @param grammarPool The grammar pool to use.
228      */

229     public SchemaParsingConfig(SymbolTable symbolTable,
230             XMLGrammarPool grammarPool) {
231         this(symbolTable, grammarPool, null);
232     } // <init>(SymbolTable,XMLGrammarPool)
233

234     /**
235      * Constructs a parser configuration using the specified symbol table,
236      * grammar pool, and parent settings.
237      * <p>
238      * <strong>REVISIT:</strong>
239      * Grammar pool will be updated when the new validation engine is
240      * implemented.
241      *
242      * @param symbolTable The symbol table to use.
243      * @param grammarPool The grammar pool to use.
244      * @param parentSettings The parent settings.
245      */

246     public SchemaParsingConfig(SymbolTable symbolTable,
247             XMLGrammarPool grammarPool,
248             XMLComponentManager parentSettings) {
249         super(symbolTable, parentSettings);
250         
251         // add default recognized features
252
final String JavaDoc[] recognizedFeatures = {
253             PARSER_SETTINGS, WARN_ON_DUPLICATE_ATTDEF, WARN_ON_UNDECLARED_ELEMDEF,
254             ALLOW_JAVA_ENCODINGS, CONTINUE_AFTER_FATAL_ERROR,
255             LOAD_EXTERNAL_DTD, NOTIFY_BUILTIN_REFS,
256             NOTIFY_CHAR_REFS, GENERATE_SYNTHETIC_ANNOTATION
257         };
258         addRecognizedFeatures(recognizedFeatures);
259         fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
260         // set state for default features
261
fFeatures.put(WARN_ON_DUPLICATE_ATTDEF, Boolean.FALSE);
262         //setFeature(WARN_ON_DUPLICATE_ENTITYDEF, false);
263
fFeatures.put(WARN_ON_UNDECLARED_ELEMDEF, Boolean.FALSE);
264         fFeatures.put(ALLOW_JAVA_ENCODINGS, Boolean.FALSE);
265         fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
266         fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
267         fFeatures.put(NOTIFY_BUILTIN_REFS, Boolean.FALSE);
268         fFeatures.put(NOTIFY_CHAR_REFS, Boolean.FALSE);
269         fFeatures.put(GENERATE_SYNTHETIC_ANNOTATION, Boolean.FALSE);
270         
271         // add default recognized properties
272
final String JavaDoc[] recognizedProperties = {
273             ERROR_REPORTER,
274             ENTITY_MANAGER,
275             DOCUMENT_SCANNER,
276             DTD_SCANNER,
277             DTD_VALIDATOR,
278             NAMESPACE_BINDER,
279             XMLGRAMMAR_POOL,
280             DATATYPE_VALIDATOR_FACTORY,
281             VALIDATION_MANAGER,
282             GENERATE_SYNTHETIC_ANNOTATION
283         };
284         addRecognizedProperties(recognizedProperties);
285         
286         fGrammarPool = grammarPool;
287         if(fGrammarPool != null){
288             setProperty(XMLGRAMMAR_POOL, fGrammarPool);
289         }
290         
291         fEntityManager = new XMLEntityManager();
292         fProperties.put(ENTITY_MANAGER, fEntityManager);
293         addComponent(fEntityManager);
294         
295         fErrorReporter = new XMLErrorReporter();
296         fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner());
297         fProperties.put(ERROR_REPORTER, fErrorReporter);
298         addComponent(fErrorReporter);
299         
300         fScanner = new XMLNSDocumentScannerImpl();
301         fProperties.put(DOCUMENT_SCANNER, fScanner);
302         addComponent((XMLComponent)fScanner);
303         
304         fDTDScanner = new XMLDTDScannerImpl();
305         fProperties.put(DTD_SCANNER, fDTDScanner);
306         addComponent((XMLComponent)fDTDScanner);
307         
308         
309         fDatatypeValidatorFactory = DTDDVFactory.getInstance();;
310         fProperties.put(DATATYPE_VALIDATOR_FACTORY,
311                 fDatatypeValidatorFactory);
312         
313         fValidationManager = new ValidationManager();
314         fProperties.put(VALIDATION_MANAGER, fValidationManager);
315         
316         // add message formatters
317
if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) {
318             XMLMessageFormatter xmft = new XMLMessageFormatter();
319             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XML_DOMAIN, xmft);
320             fErrorReporter.putMessageFormatter(XMLMessageFormatter.XMLNS_DOMAIN, xmft);
321         }
322         
323         if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
324             XSMessageFormatter xmft = new XSMessageFormatter();
325             fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
326         }
327         
328         // set locale
329
try {
330             setLocale(Locale.getDefault());
331         }
332         catch (XNIException e) {
333             // do nothing
334
// REVISIT: What is the right thing to do? -Ac
335
}
336         
337     } // <init>(SymbolTable,XMLGrammarPool)
338

339     //
340
// Public methods
341
//
342

343     /**
344      * Set the locale to use for messages.
345      *
346      * @param locale The locale object to use for localization of messages.
347      *
348      * @exception XNIException Thrown if the parser does not support the
349      * specified locale.
350      */

351     public void setLocale(Locale JavaDoc locale) throws XNIException {
352         super.setLocale(locale);
353         fErrorReporter.setLocale(locale);
354     } // setLocale(Locale)
355

356     //
357
// XMLPullParserConfiguration methods
358
//
359

360     // parsing
361

362     /**
363      * Sets the input source for the document to parse.
364      *
365      * @param inputSource The document's input source.
366      *
367      * @exception XMLConfigurationException Thrown if there is a
368      * configuration error when initializing the
369      * parser.
370      * @exception IOException Thrown on I/O error.
371      *
372      * @see #parse(boolean)
373      */

374     public void setInputSource(XMLInputSource inputSource)
375     throws XMLConfigurationException, IOException JavaDoc {
376         
377         // REVISIT: this method used to reset all the components and
378
// construct the pipeline. Now reset() is called
379
// in parse (boolean) just before we parse the document
380
// Should this method still throw exceptions..?
381

382         fInputSource = inputSource;
383         
384     } // setInputSource(XMLInputSource)
385

386     /**
387      * Parses the document in a pull parsing fashion.
388      *
389      * @param complete True if the pull parser should parse the
390      * remaining document completely.
391      *
392      * @return True if there is more document to parse.
393      *
394      * @exception XNIException Any XNI exception, possibly wrapping
395      * another exception.
396      * @exception IOException An IO exception from the parser, possibly
397      * from a byte stream or character stream
398      * supplied by the parser.
399      *
400      * @see #setInputSource
401      */

402     public boolean parse(boolean complete) throws XNIException, IOException JavaDoc {
403         //
404
// reset and configure pipeline and set InputSource.
405
if (fInputSource !=null) {
406             try {
407                 // resets and sets the pipeline.
408
reset();
409                 fScanner.setInputSource(fInputSource);
410                 fInputSource = null;
411             }
412             catch (XNIException ex) {
413                 if (PRINT_EXCEPTION_STACK_TRACE)
414                     ex.printStackTrace();
415                 throw ex;
416             }
417             catch (IOException JavaDoc ex) {
418                 if (PRINT_EXCEPTION_STACK_TRACE)
419                     ex.printStackTrace();
420                 throw ex;
421             }
422             catch (RuntimeException JavaDoc ex) {
423                 if (PRINT_EXCEPTION_STACK_TRACE)
424                     ex.printStackTrace();
425                 throw ex;
426             }
427             catch (Exception JavaDoc ex) {
428                 if (PRINT_EXCEPTION_STACK_TRACE)
429                     ex.printStackTrace();
430                 throw new XNIException(ex);
431             }
432         }
433         
434         try {
435             return fScanner.scanDocument(complete);
436         }
437         catch (XNIException ex) {
438             if (PRINT_EXCEPTION_STACK_TRACE)
439                 ex.printStackTrace();
440             throw ex;
441         }
442         catch (IOException JavaDoc ex) {
443             if (PRINT_EXCEPTION_STACK_TRACE)
444                 ex.printStackTrace();
445             throw ex;
446         }
447         catch (RuntimeException JavaDoc ex) {
448             if (PRINT_EXCEPTION_STACK_TRACE)
449                 ex.printStackTrace();
450             throw ex;
451         }
452         catch (Exception JavaDoc ex) {
453             if (PRINT_EXCEPTION_STACK_TRACE)
454                 ex.printStackTrace();
455             throw new XNIException(ex);
456         }
457         
458     } // parse(boolean):boolean
459

460     /**
461      * If the application decides to terminate parsing before the xml document
462      * is fully parsed, the application should call this method to free any
463      * resource allocated during parsing. For example, close all opened streams.
464      */

465     public void cleanup() {
466         fEntityManager.closeReaders();
467     }
468     
469     //
470
// XMLParserConfiguration methods
471
//
472

473     /**
474      * Parses the specified input source.
475      *
476      * @param source The input source.
477      *
478      * @exception XNIException Throws exception on XNI error.
479      * @exception java.io.IOException Throws exception on i/o error.
480      */

481     public void parse(XMLInputSource source) throws XNIException, IOException JavaDoc {
482         
483         if (fParseInProgress) {
484             // REVISIT - need to add new error message
485
throw new XNIException("FWK005 parse may not be called while parsing.");
486         }
487         fParseInProgress = true;
488         
489         try {
490             setInputSource(source);
491             parse(true);
492         }
493         catch (XNIException ex) {
494             if (PRINT_EXCEPTION_STACK_TRACE)
495                 ex.printStackTrace();
496             throw ex;
497         }
498         catch (IOException JavaDoc ex) {
499             if (PRINT_EXCEPTION_STACK_TRACE)
500                 ex.printStackTrace();
501             throw ex;
502         }
503         catch (RuntimeException JavaDoc ex) {
504             if (PRINT_EXCEPTION_STACK_TRACE)
505                 ex.printStackTrace();
506             throw ex;
507         }
508         catch (Exception JavaDoc ex) {
509             if (PRINT_EXCEPTION_STACK_TRACE)
510                 ex.printStackTrace();
511             throw new XNIException(ex);
512         }
513         finally {
514             fParseInProgress = false;
515             // close all streams opened by xerces
516
this.cleanup();
517         }
518         
519     } // parse(InputSource)
520

521     //
522
// Protected methods
523
//
524

525     /**
526      * Reset all components before parsing.
527      *
528      * @throws XNIException Thrown if an error occurs during initialization.
529      */

530     public void reset() throws XNIException {
531         
532         // set handlers
533
if (fSchemaDOMParser == null)
534             fSchemaDOMParser = new SchemaDOMParser(this);
535         fDocumentHandler = fSchemaDOMParser;
536         fDTDHandler = fSchemaDOMParser;
537         fDTDContentModelHandler = fSchemaDOMParser;
538         
539         // configure the pipeline and initialize the components
540
configurePipeline();
541         super.reset();
542         
543     } // reset()
544

545     /** Configures the pipeline. */
546     protected void configurePipeline() {
547         
548         // setup document pipeline
549
fScanner.setDocumentHandler(fDocumentHandler);
550         fDocumentHandler.setDocumentSource(fScanner);
551         fLastComponent = fScanner;
552         
553         // setup dtd pipeline
554
if (fDTDScanner != null) {
555             fDTDScanner.setDTDHandler(fDTDHandler);
556             fDTDScanner.setDTDContentModelHandler(fDTDContentModelHandler);
557         }
558         
559         
560     } // configurePipeline()
561

562     // features and properties
563

564     /**
565      * Check a feature. If feature is know and supported, this method simply
566      * returns. Otherwise, the appropriate exception is thrown.
567      *
568      * @param featureId The unique identifier (URI) of the feature.
569      *
570      * @throws XMLConfigurationException Thrown for configuration error.
571      * In general, components should
572      * only throw this exception if
573      * it is <strong>really</strong>
574      * a critical error.
575      */

576     protected void checkFeature(String JavaDoc featureId)
577     throws XMLConfigurationException {
578         
579         //
580
// Xerces Features
581
//
582

583         if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) {
584             final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length();
585             
586             //
587
// http://apache.org/xml/features/validation/dynamic
588
// Allows the parser to validate a document only when it
589
// contains a grammar. Validation is turned on/off based
590
// on each document instance, automatically.
591
//
592
if (suffixLength == Constants.DYNAMIC_VALIDATION_FEATURE.length() &&
593                     featureId.endsWith(Constants.DYNAMIC_VALIDATION_FEATURE)) {
594                 return;
595             }
596             //
597
// http://apache.org/xml/features/validation/default-attribute-values
598
//
599
if (suffixLength == Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE.length() &&
600                     featureId.endsWith(Constants.DEFAULT_ATTRIBUTE_VALUES_FEATURE)) {
601                 // REVISIT
602
short type = XMLConfigurationException.NOT_SUPPORTED;
603                 throw new XMLConfigurationException(type, featureId);
604             }
605             //
606
// http://apache.org/xml/features/validation/default-attribute-values
607
//
608
if (suffixLength == Constants.VALIDATE_CONTENT_MODELS_FEATURE.length() &&
609                     featureId.endsWith(Constants.VALIDATE_CONTENT_MODELS_FEATURE)) {
610                 // REVISIT
611
short type = XMLConfigurationException.NOT_SUPPORTED;
612                 throw new XMLConfigurationException(type, featureId);
613             }
614             //
615
// http://apache.org/xml/features/validation/nonvalidating/load-dtd-grammar
616
//
617
if (suffixLength == Constants.LOAD_DTD_GRAMMAR_FEATURE.length() &&
618                     featureId.endsWith(Constants.LOAD_DTD_GRAMMAR_FEATURE)) {
619                 return;
620             }
621             //
622
// http://apache.org/xml/features/validation/nonvalidating/load-external-dtd
623
//
624
if (suffixLength == Constants.LOAD_EXTERNAL_DTD_FEATURE.length() &&
625                     featureId.endsWith(Constants.LOAD_EXTERNAL_DTD_FEATURE)) {
626                 return;
627             }
628             
629             //
630
// http://apache.org/xml/features/validation/default-attribute-values
631
//
632
if (suffixLength == Constants.VALIDATE_DATATYPES_FEATURE.length() &&
633                     featureId.endsWith(Constants.VALIDATE_DATATYPES_FEATURE)) {
634                 short type = XMLConfigurationException.NOT_SUPPORTED;
635                 throw new XMLConfigurationException(type, featureId);
636             }
637         }
638         
639         //
640
// Not recognized
641
//
642

643         super.checkFeature(featureId);
644         
645     } // checkFeature(String)
646

647     /**
648      * Check a property. If the property is know and supported, this method
649      * simply returns. Otherwise, the appropriate exception is thrown.
650      *
651      * @param propertyId The unique identifier (URI) of the property
652      * being set.
653      *
654      * @throws XMLConfigurationException Thrown for configuration error.
655      * In general, components should
656      * only throw this exception if
657      * it is <strong>really</strong>
658      * a critical error.
659      */

660     protected void checkProperty(String JavaDoc propertyId)
661     throws XMLConfigurationException {
662         
663         //
664
// Xerces Properties
665
//
666

667         if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) {
668             final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length();
669             
670             if (suffixLength == Constants.DTD_SCANNER_PROPERTY.length() &&
671                     propertyId.endsWith(Constants.DTD_SCANNER_PROPERTY)) {
672                 return;
673             }
674         }
675         
676         if (propertyId.startsWith(Constants.JAXP_PROPERTY_PREFIX)) {
677             final int suffixLength = propertyId.length() - Constants.JAXP_PROPERTY_PREFIX.length();
678             
679             if (suffixLength == Constants.SCHEMA_SOURCE.length() &&
680                     propertyId.endsWith(Constants.SCHEMA_SOURCE)) {
681                 return;
682             }
683         }
684         
685         //
686
// Not recognized
687
//
688

689         super.checkProperty(propertyId);
690         
691     } // checkProperty(String)
692

693     
694     
695     //
696
// other methods
697
//
698

699     /** Returns the Document object. */
700     public Document JavaDoc getDocument() {
701         return fSchemaDOMParser.getDocument();
702     }
703     
704     /** */
705     public void resetNodePool() {
706         // REVISIT: to implement: introduce a node pool to reuse DTM nodes.
707
// reset this pool here.
708
}
709 }
710
Popular Tags