1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Copyright 2000-2005 The Apache Software Foundation. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 package com.sun.org.apache.xerces.internal.jaxp; 22 23 import java.io.IOException; 24 import java.util.HashMap; 25 import java.util.Hashtable; 26 import java.util.Iterator; 27 import java.util.Map; 28 29 import javax.xml.XMLConstants; 30 import javax.xml.validation.Schema; 31 32 import com.sun.org.apache.xerces.internal.impl.Constants; 33 import com.sun.org.apache.xerces.internal.impl.validation.ValidationManager; 34 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator; 35 import com.sun.org.apache.xerces.internal.jaxp.validation.XSGrammarPoolContainer; 36 import com.sun.org.apache.xerces.internal.util.SAXMessageFormatter; 37 import com.sun.org.apache.xerces.internal.util.SecurityManager; 38 import com.sun.org.apache.xerces.internal.util.Status; 39 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler; 40 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponent; 41 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; 42 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; 43 import com.sun.org.apache.xerces.internal.xni.parser.XMLDocumentSource; 44 import com.sun.org.apache.xerces.internal.xni.parser.XMLParserConfiguration; 45 import com.sun.org.apache.xerces.internal.xs.AttributePSVI; 46 import com.sun.org.apache.xerces.internal.xs.ElementPSVI; 47 import com.sun.org.apache.xerces.internal.xs.PSVIProvider; 48 import org.xml.sax.EntityResolver; 49 import org.xml.sax.ErrorHandler; 50 import org.xml.sax.HandlerBase; 51 import org.xml.sax.InputSource; 52 import org.xml.sax.Parser; 53 import org.xml.sax.SAXException; 54 import org.xml.sax.SAXNotRecognizedException; 55 import org.xml.sax.SAXNotSupportedException; 56 import org.xml.sax.XMLReader; 57 import org.xml.sax.helpers.DefaultHandler; 58 59 /** 60 * This is the implementation specific class for the 61 * <code>javax.xml.parsers.SAXParser</code>. 62 * 63 * @author Rajiv Mordani 64 * @author Edwin Goei 65 * 66 * @version $Id: SAXParserImpl.java,v 1.7 2010-11-01 04:40:06 joehw Exp $ 67 */ 68 public class SAXParserImpl extends javax.xml.parsers.SAXParser 69 implements JAXPConstants, PSVIProvider { 70 71 /** Feature identifier: namespaces. */ 72 private static final String NAMESPACES_FEATURE = 73 Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE; 74 75 /** Feature identifier: namespace prefixes. */ 76 private static final String NAMESPACE_PREFIXES_FEATURE = 77 Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACE_PREFIXES_FEATURE; 78 79 /** Feature identifier: validation. */ 80 private static final String VALIDATION_FEATURE = 81 Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE; 82 83 /** Feature identifier: XML Schema validation */ 84 private static final String XMLSCHEMA_VALIDATION_FEATURE = 85 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE; 86 87 /** Feature identifier: XInclude processing */ 88 private static final String XINCLUDE_FEATURE = 89 Constants.XERCES_FEATURE_PREFIX + Constants.XINCLUDE_FEATURE; 90 91 /** Property identifier: security manager. */ 92 private static final String SECURITY_MANAGER = 93 Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY; 94 95 /** property identifier: access external dtd. */ 96 public static final String ACCESS_EXTERNAL_DTD = XMLConstants.ACCESS_EXTERNAL_DTD; 97 98 /** Property identifier: access to external schema */ 99 public static final String ACCESS_EXTERNAL_SCHEMA = XMLConstants.ACCESS_EXTERNAL_SCHEMA; 100 101 private final JAXPSAXParser xmlReader; 102 private String schemaLanguage = null; // null means DTD 103 private final Schema grammar; 104 105 private final XMLComponent fSchemaValidator; 106 private final XMLComponentManager fSchemaValidatorComponentManager; 107 private final ValidationManager fSchemaValidationManager; 108 private final UnparsedEntityHandler fUnparsedEntityHandler; 109 110 /** Initial ErrorHandler */ 111 private final ErrorHandler fInitErrorHandler; 112 113 /** Initial EntityResolver */ 114 private final EntityResolver fInitEntityResolver; 115 116 /** 117 * Create a SAX parser with the associated features 118 * @param features Hashtable of SAX features, may be null 119 */ 120 SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features) 121 throws SAXException { 122 this(spf, features, false); 123 } 124 125 /** 126 * Create a SAX parser with the associated features 127 * @param features Hashtable of SAX features, may be null 128 */ 129 SAXParserImpl(SAXParserFactoryImpl spf, Hashtable features, boolean secureProcessing) 130 throws SAXException 131 { 132 // Instantiate a SAXParser directly and not through SAX so that we use the right ClassLoader 133 xmlReader = new JAXPSAXParser(this); 134 135 // JAXP "namespaceAware" == SAX Namespaces feature 136 // Note: there is a compatibility problem here with default values: 137 // JAXP default is false while SAX 2 default is true! 138 xmlReader.setFeature0(NAMESPACES_FEATURE, spf.isNamespaceAware()); 139 140 // SAX "namespaces" and "namespace-prefixes" features should not 141 // both be false. We make them opposite for backward compatibility 142 // since JAXP 1.0 apps may want to receive xmlns* attributes. 143 xmlReader.setFeature0(NAMESPACE_PREFIXES_FEATURE, !spf.isNamespaceAware()); 144 145 // Avoid setting the XInclude processing feature if the value is false. 146 // This will keep the configuration from throwing an exception if it 147 // does not support XInclude. 148 if (spf.isXIncludeAware()) { 149 xmlReader.setFeature0(XINCLUDE_FEATURE, true); 150 } 151 152 // If the secure processing feature is on set a security manager. 153 if (secureProcessing) { 154 xmlReader.setProperty0(SECURITY_MANAGER, new SecurityManager()); 155 /** 156 * By default, secure processing is set, no external access is allowed. 157 * However, we need to check if it is actively set on the factory since we 158 * allow the use of the System Property or jaxp.properties to override 159 * the default value 160 */ 161 if (features != null) { 162 Object temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING); 163 if (temp != null) { 164 boolean value = ((Boolean) temp).booleanValue(); 165 if (value) { 166 xmlReader.setProperty0(ACCESS_EXTERNAL_DTD, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); 167 xmlReader.setProperty0(ACCESS_EXTERNAL_SCHEMA, Constants.EXTERNAL_ACCESS_DEFAULT_FSP); 168 } 169 } 170 } 171 } 172 173 // Set application's features, followed by validation features. 174 setFeatures(features); 175 176 // If validating, provide a default ErrorHandler that prints 177 // validation errors with a warning telling the user to set an 178 // ErrorHandler. 179 if (spf.isValidating()) { 180 fInitErrorHandler = new DefaultValidationErrorHandler(); 181 xmlReader.setErrorHandler(fInitErrorHandler); 182 } 183 else { 184 fInitErrorHandler = xmlReader.getErrorHandler(); 185 } 186 xmlReader.setFeature0(VALIDATION_FEATURE, spf.isValidating()); 187 188 // Get the Schema object from the factory 189 this.grammar = spf.getSchema(); 190 if (grammar != null) { 191 XMLParserConfiguration config = xmlReader.getXMLParserConfiguration(); 192 XMLComponent validatorComponent = null; 193 /** For Xerces grammars, use built-in schema validator. **/ 194 if (grammar instanceof XSGrammarPoolContainer) { 195 validatorComponent = new XMLSchemaValidator(); 196 fSchemaValidationManager = new ValidationManager(); 197 fUnparsedEntityHandler = new UnparsedEntityHandler(fSchemaValidationManager); 198 config.setDTDHandler(fUnparsedEntityHandler); 199 fUnparsedEntityHandler.setDTDHandler(xmlReader); 200 xmlReader.setDTDSource(fUnparsedEntityHandler); 201 fSchemaValidatorComponentManager = new SchemaValidatorConfiguration(config, 202 (XSGrammarPoolContainer) grammar, fSchemaValidationManager); 203 } 204 /** For third party grammars, use the JAXP validator component. **/ 205 else { 206 validatorComponent = new JAXPValidatorComponent(grammar.newValidatorHandler()); 207 fSchemaValidationManager = null; 208 fUnparsedEntityHandler = null; 209 fSchemaValidatorComponentManager = config; 210 } 211 config.addRecognizedFeatures(validatorComponent.getRecognizedFeatures()); 212 config.addRecognizedProperties(validatorComponent.getRecognizedProperties()); 213 config.setDocumentHandler((XMLDocumentHandler) validatorComponent); 214 ((XMLDocumentSource)validatorComponent).setDocumentHandler(xmlReader); 215 xmlReader.setDocumentSource((XMLDocumentSource) validatorComponent); 216 fSchemaValidator = validatorComponent; 217 } 218 else { 219 fSchemaValidationManager = null; 220 fUnparsedEntityHandler = null; 221 fSchemaValidatorComponentManager = null; 222 fSchemaValidator = null; 223 } 224 225 // Initial EntityResolver 226 fInitEntityResolver = xmlReader.getEntityResolver(); 227 } 228 229 /** 230 * Set any features of our XMLReader based on any features set on the 231 * SAXParserFactory. 232 * 233 * XXX Does not handle possible conflicts between SAX feature names and 234 * JAXP specific feature names, eg. SAXParserFactory.isValidating() 235 */ 236 private void setFeatures(Hashtable features) 237 throws SAXNotSupportedException, SAXNotRecognizedException { 238 if (features != null) { 239 Iterator entries = features.entrySet().iterator(); 240 while (entries.hasNext()) { 241 Map.Entry entry = (Map.Entry) entries.next(); 242 String feature = (String) entry.getKey(); 243 boolean value = ((Boolean) entry.getValue()).booleanValue(); 244 xmlReader.setFeature0(feature, value); 245 if (feature.equals(XMLConstants.FEATURE_SECURE_PROCESSING) && value) { 246 xmlReader.setProperty0(ACCESS_EXTERNAL_DTD, ""); 247 xmlReader.setProperty0(ACCESS_EXTERNAL_SCHEMA, ""); 248 } 249 } 250 } 251 } 252 253 public Parser getParser() throws SAXException { 254 // Xerces2 AbstractSAXParser implements SAX1 Parser 255 // assert(xmlReader instanceof Parser); 256 return (Parser) xmlReader; 257 } 258 259 /** 260 * Returns the XMLReader that is encapsulated by the implementation of 261 * this class. 262 */ 263 public XMLReader getXMLReader() { 264 return xmlReader; 265 } 266 267 public boolean isNamespaceAware() { 268 try { 269 return xmlReader.getFeature(NAMESPACES_FEATURE); 270 } 271 catch (SAXException x) { 272 throw new IllegalStateException(x.getMessage()); 273 } 274 } 275 276 public boolean isValidating() { 277 try { 278 return xmlReader.getFeature(VALIDATION_FEATURE); 279 } 280 catch (SAXException x) { 281 throw new IllegalStateException(x.getMessage()); 282 } 283 } 284 285 /** 286 * Gets the XInclude processing mode for this parser 287 * @return the state of XInclude processing mode 288 */ 289 public boolean isXIncludeAware() { 290 try { 291 return xmlReader.getFeature(XINCLUDE_FEATURE); 292 } 293 catch (SAXException exc) { 294 return false; 295 } 296 } 297 298 /** 299 * Sets the particular property in the underlying implementation of 300 * org.xml.sax.XMLReader. 301 */ 302 public void setProperty(String name, Object value) 303 throws SAXNotRecognizedException, SAXNotSupportedException { 304 xmlReader.setProperty(name, value); 305 } 306 307 /** 308 * returns the particular property requested for in the underlying 309 * implementation of org.xml.sax.XMLReader. 310 */ 311 public Object getProperty(String name) 312 throws SAXNotRecognizedException, SAXNotSupportedException { 313 return xmlReader.getProperty(name); 314 } 315 316 public void parse(InputSource is, DefaultHandler dh) 317 throws SAXException, IOException { 318 if (is == null) { 319 throw new IllegalArgumentException(); 320 } 321 if (dh != null) { 322 xmlReader.setContentHandler(dh); 323 xmlReader.setEntityResolver(dh); 324 xmlReader.setErrorHandler(dh); 325 xmlReader.setDTDHandler(dh); 326 xmlReader.setDocumentHandler(null); 327 } 328 xmlReader.parse(is); 329 } 330 331 public void parse(InputSource is, HandlerBase hb) 332 throws SAXException, IOException { 333 if (is == null) { 334 throw new IllegalArgumentException(); 335 } 336 if (hb != null) { 337 xmlReader.setDocumentHandler(hb); 338 xmlReader.setEntityResolver(hb); 339 xmlReader.setErrorHandler(hb); 340 xmlReader.setDTDHandler(hb); 341 xmlReader.setContentHandler(null); 342 } 343 xmlReader.parse(is); 344 } 345 346 public Schema getSchema() { 347 return grammar; 348 } 349 350 public void reset() { 351 try { 352 /** Restore initial values of features and properties. **/ 353 xmlReader.restoreInitState(); 354 } 355 catch (SAXException exc) { 356 // This should never happen. We only store recognized 357 // features and properties in the hash maps. For now 358 // just ignore it. 359 } 360 /** Restore various handlers. **/ 361 xmlReader.setContentHandler(null); 362 xmlReader.setDTDHandler(null); 363 if (xmlReader.getErrorHandler() != fInitErrorHandler) { 364 xmlReader.setErrorHandler(fInitErrorHandler); 365 } 366 if (xmlReader.getEntityResolver() != fInitEntityResolver) { 367 xmlReader.setEntityResolver(fInitEntityResolver); 368 } 369 } 370 371 /* 372 * PSVIProvider methods 373 */ 374 375 public ElementPSVI getElementPSVI() { 376 return ((PSVIProvider)xmlReader).getElementPSVI(); 377 } 378 379 public AttributePSVI getAttributePSVI(int index) { 380 return ((PSVIProvider)xmlReader).getAttributePSVI(index); 381 } 382 383 public AttributePSVI getAttributePSVIByName(String uri, String localname) { 384 return ((PSVIProvider)xmlReader).getAttributePSVIByName(uri, localname); 385 } 386 387 /** 388 * Extension of SAXParser. This class tracks changes to 389 * features and properties to allow the parser to be reset to 390 * its initial state. 391 */ 392 public static class JAXPSAXParser extends com.sun.org.apache.xerces.internal.parsers.SAXParser { 393 394 private final HashMap fInitFeatures = new HashMap(); 395 private final HashMap fInitProperties = new HashMap(); 396 private final SAXParserImpl fSAXParser; 397 398 public JAXPSAXParser() { 399 this(null); 400 } 401 402 JAXPSAXParser(SAXParserImpl saxParser) { 403 super(); 404 fSAXParser = saxParser; 405 } 406 407 /** 408 * Override SAXParser's setFeature method to track the initial state 409 * of features. This keeps us from affecting the performance of the 410 * SAXParser when it is created with XMLReaderFactory. 411 */ 412 public synchronized void setFeature(String name, boolean value) 413 throws SAXNotRecognizedException, SAXNotSupportedException { 414 if (name == null) { 415 // TODO: Add localized error message. 416 throw new NullPointerException(); 417 } 418 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 419 try { 420 setProperty(SECURITY_MANAGER, value ? new SecurityManager() : null); 421 } 422 catch (SAXNotRecognizedException exc) { 423 // If the property is not supported 424 // re-throw the exception if the value is true. 425 if (value) { 426 throw exc; 427 } 428 } 429 catch (SAXNotSupportedException exc) { 430 // If the property is not supported 431 // re-throw the exception if the value is true. 432 if (value) { 433 throw exc; 434 } 435 } 436 return; 437 } 438 if (!fInitFeatures.containsKey(name)) { 439 boolean current = super.getFeature(name); 440 fInitFeatures.put(name, current ? Boolean.TRUE : Boolean.FALSE); 441 } 442 /** Forward feature to the schema validator if there is one. **/ 443 if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { 444 setSchemaValidatorFeature(name, value); 445 } 446 super.setFeature(name, value); 447 } 448 449 public synchronized boolean getFeature(String name) 450 throws SAXNotRecognizedException, SAXNotSupportedException { 451 if (name == null) { 452 // TODO: Add localized error message. 453 throw new NullPointerException(); 454 } 455 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 456 try { 457 return (super.getProperty(SECURITY_MANAGER) != null); 458 } 459 // If the property is not supported the value must be false. 460 catch (SAXException exc) { 461 return false; 462 } 463 } 464 return super.getFeature(name); 465 } 466 467 /** 468 * Override SAXParser's setProperty method to track the initial state 469 * of properties. This keeps us from affecting the performance of the 470 * SAXParser when it is created with XMLReaderFactory. 471 */ 472 public synchronized void setProperty(String name, Object value) 473 throws SAXNotRecognizedException, SAXNotSupportedException { 474 if (name == null) { 475 // TODO: Add localized error message. 476 throw new NullPointerException(); 477 } 478 if (fSAXParser != null) { 479 // JAXP 1.2 support 480 if (JAXP_SCHEMA_LANGUAGE.equals(name)) { 481 // The spec says if a schema is given via SAXParserFactory 482 // the JAXP 1.2 properties shouldn't be allowed. 483 if (fSAXParser.grammar != null) { 484 throw new SAXNotSupportedException( 485 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object[] {name})); 486 } 487 if ( W3C_XML_SCHEMA.equals(value) ) { 488 //None of the properties will take effect till the setValidating(true) has been called 489 if( fSAXParser.isValidating() ) { 490 fSAXParser.schemaLanguage = W3C_XML_SCHEMA; 491 setFeature(XMLSCHEMA_VALIDATION_FEATURE, true); 492 // this will allow the parser not to emit DTD-related 493 // errors, as the spec demands 494 if (!fInitProperties.containsKey(JAXP_SCHEMA_LANGUAGE)) { 495 fInitProperties.put(JAXP_SCHEMA_LANGUAGE, super.getProperty(JAXP_SCHEMA_LANGUAGE)); 496 } 497 super.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); 498 } 499 500 } 501 else if (value == null) { 502 fSAXParser.schemaLanguage = null; 503 setFeature(XMLSCHEMA_VALIDATION_FEATURE, false); 504 } 505 else { 506 // REVISIT: It would be nice if we could format this message 507 // using a user specified locale as we do in the underlying 508 // XMLReader -- mrglavas 509 throw new SAXNotSupportedException( 510 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-not-supported", null)); 511 } 512 return; 513 } 514 else if (JAXP_SCHEMA_SOURCE.equals(name)) { 515 // The spec says if a schema is given via SAXParserFactory 516 // the JAXP 1.2 properties shouldn't be allowed. 517 if (fSAXParser.grammar != null) { 518 throw new SAXNotSupportedException( 519 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), "schema-already-specified", new Object[] {name})); 520 } 521 String val = (String)getProperty(JAXP_SCHEMA_LANGUAGE); 522 if ( val != null && W3C_XML_SCHEMA.equals(val) ) { 523 if (!fInitProperties.containsKey(JAXP_SCHEMA_SOURCE)) { 524 fInitProperties.put(JAXP_SCHEMA_SOURCE, super.getProperty(JAXP_SCHEMA_SOURCE)); 525 } 526 super.setProperty(name, value); 527 } 528 else { 529 throw new SAXNotSupportedException( 530 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), 531 "jaxp-order-not-supported", 532 new Object[] {JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE})); 533 } 534 return; 535 } 536 } 537 if (!fInitProperties.containsKey(name)) { 538 fInitProperties.put(name, super.getProperty(name)); 539 } 540 /** Forward property to the schema validator if there is one. **/ 541 if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { 542 setSchemaValidatorProperty(name, value); 543 } 544 super.setProperty(name, value); 545 } 546 547 public synchronized Object getProperty(String name) 548 throws SAXNotRecognizedException, SAXNotSupportedException { 549 if (name == null) { 550 // TODO: Add localized error message. 551 throw new NullPointerException(); 552 } 553 if (fSAXParser != null && JAXP_SCHEMA_LANGUAGE.equals(name)) { 554 // JAXP 1.2 support 555 return fSAXParser.schemaLanguage; 556 } 557 return super.getProperty(name); 558 } 559 560 synchronized void restoreInitState() 561 throws SAXNotRecognizedException, SAXNotSupportedException { 562 Iterator iter; 563 if (!fInitFeatures.isEmpty()) { 564 iter = fInitFeatures.entrySet().iterator(); 565 while (iter.hasNext()) { 566 Map.Entry entry = (Map.Entry) iter.next(); 567 String name = (String) entry.getKey(); 568 boolean value = ((Boolean) entry.getValue()).booleanValue(); 569 super.setFeature(name, value); 570 } 571 fInitFeatures.clear(); 572 } 573 if (!fInitProperties.isEmpty()) { 574 iter = fInitProperties.entrySet().iterator(); 575 while (iter.hasNext()) { 576 Map.Entry entry = (Map.Entry) iter.next(); 577 String name = (String) entry.getKey(); 578 Object value = entry.getValue(); 579 super.setProperty(name, value); 580 } 581 fInitProperties.clear(); 582 } 583 } 584 585 public void parse(InputSource inputSource) 586 throws SAXException, IOException { 587 if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { 588 if (fSAXParser.fSchemaValidationManager != null) { 589 fSAXParser.fSchemaValidationManager.reset(); 590 fSAXParser.fUnparsedEntityHandler.reset(); 591 } 592 resetSchemaValidator(); 593 } 594 super.parse(inputSource); 595 } 596 597 public void parse(String systemId) 598 throws SAXException, IOException { 599 if (fSAXParser != null && fSAXParser.fSchemaValidator != null) { 600 if (fSAXParser.fSchemaValidationManager != null) { 601 fSAXParser.fSchemaValidationManager.reset(); 602 fSAXParser.fUnparsedEntityHandler.reset(); 603 } 604 resetSchemaValidator(); 605 } 606 super.parse(systemId); 607 } 608 609 XMLParserConfiguration getXMLParserConfiguration() { 610 return fConfiguration; 611 } 612 613 void setFeature0(String name, boolean value) 614 throws SAXNotRecognizedException, SAXNotSupportedException { 615 super.setFeature(name, value); 616 } 617 618 boolean getFeature0(String name) 619 throws SAXNotRecognizedException, SAXNotSupportedException { 620 return super.getFeature(name); 621 } 622 623 void setProperty0(String name, Object value) 624 throws SAXNotRecognizedException, SAXNotSupportedException { 625 super.setProperty(name, value); 626 } 627 628 Object getProperty0(String name) 629 throws SAXNotRecognizedException, SAXNotSupportedException { 630 return super.getProperty(name); 631 } 632 633 private void setSchemaValidatorFeature(String name, boolean value) 634 throws SAXNotRecognizedException, SAXNotSupportedException { 635 try { 636 fSAXParser.fSchemaValidator.setFeature(name, value); 637 } 638 // This should never be thrown from the schema validator. 639 catch (XMLConfigurationException e) { 640 String identifier = e.getIdentifier(); 641 if (e.getType() == Status.NOT_RECOGNIZED) { 642 throw new SAXNotRecognizedException( 643 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), 644 "feature-not-recognized", new Object [] {identifier})); 645 } 646 else { 647 throw new SAXNotSupportedException( 648 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), 649 "feature-not-supported", new Object [] {identifier})); 650 } 651 } 652 } 653 654 private void setSchemaValidatorProperty(String name, Object value) 655 throws SAXNotRecognizedException, SAXNotSupportedException { 656 try { 657 fSAXParser.fSchemaValidator.setProperty(name, value); 658 } 659 // This should never be thrown from the schema validator. 660 catch (XMLConfigurationException e) { 661 String identifier = e.getIdentifier(); 662 if (e.getType() == Status.NOT_RECOGNIZED) { 663 throw new SAXNotRecognizedException( 664 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), 665 "property-not-recognized", new Object [] {identifier})); 666 } 667 else { 668 throw new SAXNotSupportedException( 669 SAXMessageFormatter.formatMessage(fConfiguration.getLocale(), 670 "property-not-supported", new Object [] {identifier})); 671 } 672 } 673 } 674 675 private void resetSchemaValidator() throws SAXException { 676 try { 677 fSAXParser.fSchemaValidator.reset(fSAXParser.fSchemaValidatorComponentManager); 678 } 679 // This should never be thrown from the schema validator. 680 catch (XMLConfigurationException e) { 681 throw new SAXException(e); 682 } 683 } 684 } 685 }