KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > xerces > jaxp > SAXParserImpl


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

16
17 package org.apache.xerces.jaxp;
18
19 import java.io.IOException JavaDoc;
20 import java.util.Enumeration JavaDoc;
21 import java.util.HashMap JavaDoc;
22 import java.util.Hashtable JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.Map JavaDoc;
25
26 import javax.xml.XMLConstants JavaDoc;
27 import javax.xml.validation.Schema JavaDoc;
28
29 import org.apache.xerces.impl.Constants;
30 import org.apache.xerces.impl.validation.ValidationManager;
31 import org.apache.xerces.impl.xs.XMLSchemaValidator;
32 import org.apache.xerces.impl.xs.XSMessageFormatter;
33 import org.apache.xerces.jaxp.validation.XSGrammarPoolContainer;
34 import org.apache.xerces.util.SAXMessageFormatter;
35 import org.apache.xerces.util.SecurityManager;
36 import org.apache.xerces.xni.XMLDocumentHandler;
37 import org.apache.xerces.xni.parser.XMLComponent;
38 import org.apache.xerces.xni.parser.XMLComponentManager;
39 import org.apache.xerces.xni.parser.XMLConfigurationException;
40 import org.apache.xerces.xni.parser.XMLDTDFilter;
41 import org.apache.xerces.xni.parser.XMLDocumentSource;
42 import org.apache.xerces.xni.parser.XMLParserConfiguration;
43 import org.apache.xerces.xs.AttributePSVI;
44 import org.apache.xerces.xs.ElementPSVI;
45 import org.apache.xerces.xs.PSVIProvider;
46 import org.xml.sax.EntityResolver JavaDoc;
47 import org.xml.sax.ErrorHandler JavaDoc;
48 import org.xml.sax.InputSource JavaDoc;
49 import org.xml.sax.Parser JavaDoc;
50 import org.xml.sax.SAXException JavaDoc;
51 import org.xml.sax.SAXNotRecognizedException JavaDoc;
52 import org.xml.sax.SAXNotSupportedException JavaDoc;
53 import org.xml.sax.XMLReader JavaDoc;
54
55 /**
56  * This is the implementation specific class for the
57  * <code>javax.xml.parsers.SAXParser</code>.
58  *
59  * @author Rajiv Mordani
60  * @author Edwin Goei
61  *
62  * @version $Id: SAXParserImpl.java,v 1.33 2005/06/21 17:19:08 mrglavas Exp $
63  */

64 public class SAXParserImpl extends javax.xml.parsers.SAXParser JavaDoc
65     implements JAXPConstants, PSVIProvider {
66     
67     /** Feature identifier: namespaces. */
68     private static final String JavaDoc NAMESPACES_FEATURE =
69         Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE;
70     
71     /** Feature identifier: namespace prefixes. */
72     private static final String JavaDoc NAMESPACE_PREFIXES_FEATURE =
73         Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE;
74     
75     /** Feature identifier: validation. */
76     private static final String JavaDoc VALIDATION_FEATURE =
77         Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE;
78     
79     /** Feature identifier: XML Schema validation */
80     private static final String JavaDoc XMLSCHEMA_VALIDATION_FEATURE =
81         Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE;
82     
83     /** Feature identifier: XInclude processing */
84     private static final String JavaDoc XINCLUDE_FEATURE =
85         Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FEATURE;
86     
87     /** Property identifier: security manager. */
88     private static final String JavaDoc SECURITY_MANAGER =
89         Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
90
91     private JAXPSAXParser xmlReader;
92     private String JavaDoc schemaLanguage = null; // null means DTD
93
private final Schema JavaDoc grammar;
94     
95     private XMLComponent fSchemaValidator;
96     private XMLComponentManager fSchemaValidatorComponentManager;
97     private ValidationManager fSchemaValidationManager;
98     
99     /** Initial ErrorHandler */
100     private final ErrorHandler JavaDoc fInitErrorHandler;
101     
102     /** Initial EntityResolver */
103     private final EntityResolver JavaDoc fInitEntityResolver;
104     
105     /**
106      * Create a SAX parser with the associated features
107      * @param features Hashtable of SAX features, may be null
108      */

109     SAXParserImpl(SAXParserFactoryImpl spf, Hashtable JavaDoc features)
110         throws SAXException JavaDoc {
111         this(spf, features, false);
112     }
113     
114     /**
115      * Create a SAX parser with the associated features
116      * @param features Hashtable of SAX features, may be null
117      */

118     SAXParserImpl(SAXParserFactoryImpl spf, Hashtable JavaDoc features, boolean secureProcessing)
119         throws SAXException JavaDoc
120     {
121         // Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader
122
xmlReader = new JAXPSAXParser(this);
123
124         // JAXP "namespaceAware" == SAX Namespaces feature
125
// Note: there is a compatibility problem here with default values:
126
// JAXP default is false while SAX 2 default is true!
127
xmlReader.setFeature0(NAMESPACES_FEATURE, spf.isNamespaceAware());
128
129         // SAX "namespaces" and "namespace-prefixes" features should not
130
// both be false. We make them opposite for backward compatibility
131
// since JAXP 1.0 apps may want to receive xmlns* attributes.
132
xmlReader.setFeature0(NAMESPACE_PREFIXES_FEATURE, !spf.isNamespaceAware());
133         
134         // Avoid setting the XInclude processing feature if the value is false.
135
// This will keep the configuration from throwing an exception if it
136
// does not support XInclude.
137
if (spf.isXIncludeAware()) {
138             xmlReader.setFeature0(XINCLUDE_FEATURE, true);
139         }
140         
141         // If the secure processing feature is on set a security manager.
142
if (secureProcessing) {
143             xmlReader.setProperty0(SECURITY_MANAGER, new SecurityManager JavaDoc());
144         }
145         
146         // Set application's features, followed by validation features.
147
setFeatures(features);
148         
149         // If validating, provide a default ErrorHandler that prints
150
// validation errors with a warning telling the user to set an
151
// ErrorHandler.
152
if (spf.isValidating()) {
153             fInitErrorHandler = new DefaultValidationErrorHandler();
154             xmlReader.setErrorHandler(fInitErrorHandler);
155         }
156         else {
157             fInitErrorHandler = xmlReader.getErrorHandler();
158         }
159         xmlReader.setFeature0(VALIDATION_FEATURE, spf.isValidating());
160         
161         // Get the Schema object from the factory
162
this.grammar = spf.getSchema();
163         if (grammar != null) {
164             XMLParserConfiguration config = xmlReader.getXMLParserConfiguration();
165             XMLComponent validatorComponent = null;
166             /** For Xerces grammars, use built-in schema validator. **/
167             if (grammar instanceof XSGrammarPoolContainer) {
168                 validatorComponent = new XMLSchemaValidator();
169                 fSchemaValidationManager = new ValidationManager();
170                 XMLDTDFilter entityHandler = new UnparsedEntityHandler(fSchemaValidationManager);
171                 config.setDTDHandler(entityHandler);
172                 entityHandler.setDTDHandler(xmlReader);
173                 xmlReader.setDTDSource(entityHandler);
174                 fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config,
175                         (XSGrammarPoolContainer) grammar, fSchemaValidationManager);
176             }
177             /** For third party grammars, use the JAXP validator component. **/
178             else {
179                 validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler());
180                 fSchemaValidatorComponentManager = config;
181             }
182             config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures());
183             config.addRecognizedProperties(validatorComponent.getRecognizedProperties());
184             config.setDocumentHandler((XMLDocumentHandler) validatorComponent);
185             ((XMLDocumentSource)validatorComponent).setDocumentHandler(xmlReader);
186             xmlReader.setDocumentSource((XMLDocumentSource) validatorComponent);
187             fSchemaValidator = validatorComponent;
188         }
189         
190         // Initial EntityResolver
191
fInitEntityResolver = xmlReader.getEntityResolver();
192     }
193
194     /**
195      * Set any features of our XMLReader based on any features set on the
196      * SAXParserFactory.
197      *
198      * XXX Does not handle possible conflicts between SAX feature names and
199      * JAXP specific feature names, eg. SAXParserFactory.isValidating()
200      */

201     private void setFeatures(Hashtable JavaDoc features)
202         throws SAXNotSupportedException JavaDoc, SAXNotRecognizedException JavaDoc {
203         if (features != null) {
204             for (Enumeration JavaDoc e = features.keys(); e.hasMoreElements();) {
205                 String JavaDoc feature = (String JavaDoc)e.nextElement();
206                 boolean value = ((Boolean JavaDoc)features.get(feature)).booleanValue();
207                 xmlReader.setFeature0(feature, value);
208             }
209         }
210     }
211
212     public Parser JavaDoc getParser() throws SAXException JavaDoc {
213         // Xerces2 AbstractSAXParser implements SAX1 Parser
214
// assert(xmlReader instanceof Parser);
215
return (Parser JavaDoc) xmlReader;
216     }
217
218     /**
219      * Returns the XMLReader that is encapsulated by the implementation of
220      * this class.
221      */

222     public XMLReader JavaDoc getXMLReader() {
223         return xmlReader;
224     }
225
226     public boolean isNamespaceAware() {
227         try {
228             return xmlReader.getFeature(NAMESPACES_FEATURE);
229         }
230         catch (SAXException JavaDoc x) {
231             throw new IllegalStateException JavaDoc(x.getMessage());
232         }
233     }
234
235     public boolean isValidating() {
236         try {
237             return xmlReader.getFeature(VALIDATION_FEATURE);
238         }
239         catch (SAXException JavaDoc x) {
240             throw new IllegalStateException JavaDoc(x.getMessage());
241         }
242     }
243     
244     /**
245      * Gets the XInclude processing mode for this parser
246      * @return the state of XInclude processing mode
247      */

248     public boolean isXIncludeAware() {
249         try {
250             return xmlReader.getFeature(XINCLUDE_FEATURE);
251         }
252         catch (SAXException JavaDoc exc) {
253             return false;
254         }
255     }
256
257     /**
258      * Sets the particular property in the underlying implementation of
259      * org.xml.sax.XMLReader.
260      */

261     public void setProperty(String JavaDoc name, Object JavaDoc value)
262         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
263         xmlReader.setProperty(name, value);
264     }
265
266     /**
267      * returns the particular property requested for in the underlying
268      * implementation of org.xml.sax.XMLReader.
269      */

270     public Object JavaDoc getProperty(String JavaDoc name)
271         throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
272         return xmlReader.getProperty(name);
273     }
274     
275     public Schema JavaDoc getSchema() {
276         return grammar;
277     }
278     
279     public void reset() {
280         try {
281             /** Restore initial values of features and properties. **/
282             xmlReader.restoreInitState();
283         }
284         catch (SAXException JavaDoc exc) {
285             // This should never happen. We only store recognized
286
// features and properties in the hash maps. For now
287
// just ignore it.
288
}
289         /** Restore various handlers. **/
290         xmlReader.setContentHandler(null);
291         xmlReader.setDTDHandler(null);
292         if (xmlReader.getErrorHandler() != fInitErrorHandler) {
293             xmlReader.setErrorHandler(fInitErrorHandler);
294         }
295         if (xmlReader.getEntityResolver() != fInitEntityResolver) {
296             xmlReader.setEntityResolver(fInitEntityResolver);
297         }
298     }
299     
300     /*
301      * PSVIProvider methods
302      */

303
304     public ElementPSVI getElementPSVI() {
305         return ((PSVIProvider)xmlReader).getElementPSVI();
306     }
307
308     public AttributePSVI getAttributePSVI(int index) {
309         return ((PSVIProvider)xmlReader).getAttributePSVI(index);
310     }
311
312     public AttributePSVI getAttributePSVIByName(String JavaDoc uri, String JavaDoc localname) {
313         return ((PSVIProvider)xmlReader).getAttributePSVIByName(uri, localname);
314     }
315     
316     /**
317      * Extension of SAXParser. This class tracks changes to
318      * features and properties to allow the parser to be reset to
319      * its initial state.
320      */

321     public static class JAXPSAXParser extends org.apache.xerces.parsers.SAXParser {
322         
323         private HashMap JavaDoc fInitFeatures = new HashMap JavaDoc();
324         private HashMap JavaDoc fInitProperties = new HashMap JavaDoc();
325         private SAXParserImpl fSAXParser;
326
327         public JAXPSAXParser() {
328             super();
329         }
330         
331         JAXPSAXParser(SAXParserImpl saxParser) {
332             super();
333             fSAXParser = saxParser;
334         }
335         
336         /**
337          * Override SAXParser's setFeature method to track the initial state
338          * of features. This keeps us from affecting the performance of the
339          * SAXParser when it is created with XMLReaderFactory.
340          */

341         public synchronized void setFeature(String JavaDoc name, boolean value)
342             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
343             if (name == null) {
344                 // TODO: Add localized error message.
345
throw new NullPointerException JavaDoc();
346             }
347             if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
348                 try {
349                     setProperty(SECURITY_MANAGER, value ? new SecurityManager JavaDoc() : null);
350                 }
351                 catch (SAXNotRecognizedException JavaDoc exc) {
352                     // If the property is not supported
353
// re-throw the exception if the value is true.
354
if (value) {
355                         throw exc;
356                     }
357                 }
358                 catch (SAXNotSupportedException JavaDoc exc) {
359                     // If the property is not supported
360
// re-throw the exception if the value is true.
361
if (value) {
362                         throw exc;
363                     }
364                 }
365                 return;
366             }
367             if (!fInitFeatures.containsKey(name)) {
368                 boolean current = super.getFeature(name);
369                 fInitFeatures.put(name, current ? Boolean.TRUE : Boolean.FALSE);
370             }
371             /** Forward feature to the schema validator if there is one. **/
372             if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
373                 setSchemaValidatorFeature(name, value);
374             }
375             super.setFeature(name, value);
376         }
377         
378         public synchronized boolean getFeature(String JavaDoc name)
379             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
380             if (name == null) {
381                 // TODO: Add localized error message.
382
throw new NullPointerException JavaDoc();
383             }
384             if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) {
385                 try {
386                     return (super.getProperty(SECURITY_MANAGER) != null);
387                 }
388                 // If the property is not supported the value must be false.
389
catch (SAXException JavaDoc exc) {
390                     return false;
391                 }
392             }
393             return super.getFeature(name);
394         }
395         
396         /**
397          * Override SAXParser's setProperty method to track the initial state
398          * of properties. This keeps us from affecting the performance of the
399          * SAXParser when it is created with XMLReaderFactory.
400          */

401         public synchronized void setProperty(String JavaDoc name, Object JavaDoc value)
402             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
403             if (name == null) {
404                 // TODO: Add localized error message.
405
throw new NullPointerException JavaDoc();
406             }
407             if (fSAXParser != null) {
408                 // JAXP 1.2 support
409
if (JAXP_SCHEMA_LANGUAGE.equals(name)) {
410                     // The spec says if a schema is given via SAXParserFactory
411
// the JAXP 1.2 properties shouldn't be allowed.
412
if (fSAXParser.grammar != null) {
413                         throw new SAXNotSupportedException JavaDoc(
414                                 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object JavaDoc[] {name}));
415                     }
416                     if ( W3C_XML_SCHEMA.equals(value) ) {
417                         //None of the properties will take effect till the setValidating(true) has been called
418
if( fSAXParser.isValidating() ) {
419                             fSAXParser.schemaLanguage = W3C_XML_SCHEMA;
420                             setFeature(XMLSCHEMA_VALIDATION_FEATURE, true);
421                             // this will allow the parser not to emit DTD-related
422
// errors, as the spec demands
423
if (!fInitProperties.containsKey(JAXP_SCHEMA_LANGUAGE)) {
424                                 fInitProperties.put(JAXP_SCHEMA_LANGUAGE, super.getProperty(JAXP_SCHEMA_LANGUAGE));
425                             }
426                             super.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
427                         }
428                         
429                     }
430                     else if (value == null) {
431                         fSAXParser.schemaLanguage = null;
432                         setFeature(XMLSCHEMA_VALIDATION_FEATURE, false);
433                     }
434                     else {
435                         // REVISIT: It would be nice if we could format this message
436
// using a user specified locale as we do in the underlying
437
// XMLReader -- mrglavas
438
throw new SAXNotSupportedException JavaDoc(
439                             SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-not-supported", null));
440                     }
441                     return;
442                 }
443                 else if (JAXP_SCHEMA_SOURCE.equals(name)) {
444                     // The spec says if a schema is given via SAXParserFactory
445
// the JAXP 1.2 properties shouldn't be allowed.
446
if (fSAXParser.grammar != null) {
447                         throw new SAXNotSupportedException JavaDoc(
448                                 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object JavaDoc[] {name}));
449                     }
450                     String JavaDoc val = (String JavaDoc)getProperty(JAXP_SCHEMA_LANGUAGE);
451                     if ( val != null && W3C_XML_SCHEMA.equals(val) ) {
452                         if (!fInitProperties.containsKey(JAXP_SCHEMA_SOURCE)) {
453                             fInitProperties.put(JAXP_SCHEMA_SOURCE, super.getProperty(JAXP_SCHEMA_SOURCE));
454                         }
455                         super.setProperty(name, value);
456                     }
457                     else {
458                         throw new SAXNotSupportedException JavaDoc(
459                             SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
460                             "jaxp-order-not-supported",
461                             new Object JavaDoc[] {JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE}));
462                     }
463                     return;
464                 }
465             }
466             if (!fInitProperties.containsKey(name)) {
467                 fInitProperties.put(name, super.getProperty(name));
468             }
469             /** Forward property to the schema validator if there is one. **/
470             if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
471                 setSchemaValidatorProperty(name, value);
472             }
473             super.setProperty(name, value);
474         }
475         
476         public synchronized Object JavaDoc getProperty(String JavaDoc name)
477             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
478             if (name == null) {
479                 // TODO: Add localized error message.
480
throw new NullPointerException JavaDoc();
481             }
482             if (fSAXParser != null && JAXP_SCHEMA_LANGUAGE.equals(name)) {
483                 // JAXP 1.2 support
484
return fSAXParser.schemaLanguage;
485             }
486             return super.getProperty(name);
487         }
488         
489         synchronized void restoreInitState()
490             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
491             Iterator JavaDoc iter;
492             if (!fInitFeatures.isEmpty()) {
493                 iter = fInitFeatures.entrySet().iterator();
494                 while (iter.hasNext()) {
495                     Map.Entry JavaDoc entry = (Map.Entry JavaDoc) iter.next();
496                     String JavaDoc name = (String JavaDoc) entry.getKey();
497                     boolean value = ((Boolean JavaDoc) entry.getValue()).booleanValue();
498                     super.setFeature(name, value);
499                 }
500                 fInitFeatures.clear();
501             }
502             if (!fInitProperties.isEmpty()) {
503                 iter = fInitProperties.entrySet().iterator();
504                 while (iter.hasNext()) {
505                     Map.Entry JavaDoc entry = (Map.Entry JavaDoc) iter.next();
506                     String JavaDoc name = (String JavaDoc) entry.getKey();
507                     Object JavaDoc value = entry.getValue();
508                     super.setProperty(name, value);
509                 }
510                 fInitProperties.clear();
511             }
512         }
513         
514         public void parse(InputSource JavaDoc inputSource)
515             throws SAXException JavaDoc, IOException JavaDoc {
516             if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
517                 if (fSAXParser.fSchemaValidationManager != null) {
518                     fSAXParser.fSchemaValidationManager.reset();
519                 }
520                 resetSchemaValidator();
521             }
522             super.parse(inputSource);
523         }
524         
525         public void parse(String JavaDoc systemId)
526             throws SAXException JavaDoc, IOException JavaDoc {
527             if (fSAXParser != null && fSAXParser.fSchemaValidator != null) {
528                 if (fSAXParser.fSchemaValidationManager != null) {
529                     fSAXParser.fSchemaValidationManager.reset();
530                 }
531                 resetSchemaValidator();
532             }
533             super.parse(systemId);
534         }
535         
536         XMLParserConfiguration getXMLParserConfiguration() {
537             return fConfiguration;
538         }
539         
540         void setFeature0(String JavaDoc name, boolean value)
541             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
542             super.setFeature(name, value);
543         }
544         
545         boolean getFeature0(String JavaDoc name)
546             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
547             return super.getFeature(name);
548         }
549         
550         void setProperty0(String JavaDoc name, Object JavaDoc value)
551             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
552             super.setProperty(name, value);
553         }
554         
555         Object JavaDoc getProperty0(String JavaDoc name)
556             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
557             return super.getProperty(name);
558         }
559         
560         private void setSchemaValidatorFeature(String JavaDoc name, boolean value)
561             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
562             try {
563                 fSAXParser.fSchemaValidator.setFeature(name, value);
564             }
565             // This should never be thrown from the schema validator.
566
catch (XMLConfigurationException e) {
567                 String JavaDoc identifier = e.getIdentifier();
568                 if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
569                     throw new SAXNotRecognizedException JavaDoc(
570                         SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
571                         "feature-not-recognized", new Object JavaDoc [] {identifier}));
572                 }
573                 else {
574                     throw new SAXNotSupportedException JavaDoc(
575                         SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
576                         "feature-not-supported", new Object JavaDoc [] {identifier}));
577                 }
578             }
579         }
580         
581         private void setSchemaValidatorProperty(String JavaDoc name, Object JavaDoc value)
582             throws SAXNotRecognizedException JavaDoc, SAXNotSupportedException JavaDoc {
583             try {
584                 fSAXParser.fSchemaValidator.setProperty(name, value);
585             }
586             // This should never be thrown from the schema validator.
587
catch (XMLConfigurationException e) {
588                 String JavaDoc identifier = e.getIdentifier();
589                 if (e.getType() == XMLConfigurationException.NOT_RECOGNIZED) {
590                     throw new SAXNotRecognizedException JavaDoc(
591                         SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
592                         "property-not-recognized", new Object JavaDoc [] {identifier}));
593                 }
594                 else {
595                     throw new SAXNotSupportedException JavaDoc(
596                         SAXMessageFormatter.formatMessage(fConfiguration.getLocale(),
597                         "property-not-supported", new Object JavaDoc [] {identifier}));
598                 }
599             }
600         }
601         
602         private void resetSchemaValidator() throws SAXException JavaDoc {
603             try {
604                 fSAXParser.fSchemaValidator.reset(fSAXParser.fSchemaValidatorComponentManager);
605             }
606             // This should never be thrown from the schema validator.
607
catch (XMLConfigurationException e) {
608                 throw new SAXException JavaDoc(e);
609             }
610         }
611     }
612 }
613
Popular Tags