1 57 58 package com.sun.org.apache.xerces.internal.parsers; 59 60 import com.sun.org.apache.xerces.internal.impl.Constants; 61 import com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator; 62 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter; 63 import com.sun.org.apache.xerces.internal.util.SymbolTable; 64 import com.sun.org.apache.xerces.internal.xni.grammars.XMLGrammarPool; 65 import com.sun.org.apache.xerces.internal.xni.parser.XMLComponentManager; 66 import com.sun.org.apache.xerces.internal.xni.parser.XMLConfigurationException; 67 68 103 public class StandardParserConfiguration 104 extends DTDConfiguration { 105 106 110 112 113 protected static final String NORMALIZE_DATA = 114 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_NORMALIZED_VALUE; 115 116 117 118 protected static final String SCHEMA_ELEMENT_DEFAULT = 119 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_ELEMENT_DEFAULT; 120 121 122 123 protected static final String SCHEMA_AUGMENT_PSVI = 124 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_AUGMENT_PSVI; 125 126 127 128 protected static final String XMLSCHEMA_VALIDATION = 129 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_VALIDATION_FEATURE; 130 131 132 protected static final String XMLSCHEMA_FULL_CHECKING = 133 Constants.XERCES_FEATURE_PREFIX + Constants.SCHEMA_FULL_CHECKING; 134 135 137 138 protected static final String SCHEMA_VALIDATOR = 139 Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY; 140 141 142 protected static final String SCHEMA_LOCATION = 143 Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_LOCATION; 144 145 146 protected static final String SCHEMA_NONS_LOCATION = 147 Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_NONS_LOCATION; 148 149 153 155 156 protected XMLSchemaValidator fSchemaValidator; 157 158 162 163 public StandardParserConfiguration() { 164 this(null, null, null); 165 } 167 172 public StandardParserConfiguration(SymbolTable symbolTable) { 173 this(symbolTable, null, null); 174 } 176 187 public StandardParserConfiguration(SymbolTable symbolTable, 188 XMLGrammarPool grammarPool) { 189 this(symbolTable, grammarPool, null); 190 } 192 204 public StandardParserConfiguration(SymbolTable symbolTable, 205 XMLGrammarPool grammarPool, 206 XMLComponentManager parentSettings) { 207 super(symbolTable, grammarPool, parentSettings); 208 209 final String [] recognizedFeatures = { 211 NORMALIZE_DATA, 212 SCHEMA_ELEMENT_DEFAULT, 213 SCHEMA_AUGMENT_PSVI, 214 XMLSCHEMA_VALIDATION, 219 XMLSCHEMA_FULL_CHECKING, 220 }; 221 addRecognizedFeatures(recognizedFeatures); 222 223 setFeature(SCHEMA_ELEMENT_DEFAULT, true); 225 setFeature(NORMALIZE_DATA, true); 226 setFeature(SCHEMA_AUGMENT_PSVI, true); 227 228 230 final String [] recognizedProperties = { 231 SCHEMA_LOCATION, 236 SCHEMA_NONS_LOCATION, 237 }; 238 239 addRecognizedProperties(recognizedProperties); 240 241 } 243 247 248 protected void configurePipeline() { 249 super.configurePipeline(); 250 if ( getFeature(XMLSCHEMA_VALIDATION )) { 251 if (fSchemaValidator == null) { 253 fSchemaValidator = new XMLSchemaValidator(); 254 255 fProperties.put(SCHEMA_VALIDATOR, fSchemaValidator); 257 addComponent(fSchemaValidator); 258 if (fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) { 260 XSMessageFormatter xmft = new XSMessageFormatter(); 261 fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft); 262 } 263 264 } 265 fLastComponent = fSchemaValidator; 266 fNamespaceBinder.setDocumentHandler(fSchemaValidator); 267 268 fSchemaValidator.setDocumentHandler(fDocumentHandler); 269 fSchemaValidator.setDocumentSource(fNamespaceBinder); 270 } 271 272 273 } 275 277 289 protected void checkFeature(String featureId) 290 throws XMLConfigurationException { 291 292 296 if (featureId.startsWith(Constants.XERCES_FEATURE_PREFIX)) { 297 final int suffixLength = featureId.length() - Constants.XERCES_FEATURE_PREFIX.length(); 298 299 if (suffixLength == Constants.SCHEMA_VALIDATION_FEATURE.length() && 304 featureId.endsWith(Constants.SCHEMA_VALIDATION_FEATURE)) { 305 return; 306 } 307 if (suffixLength == Constants.SCHEMA_FULL_CHECKING.length() && 309 featureId.endsWith(Constants.SCHEMA_FULL_CHECKING)) { 310 return; 311 } 312 if (suffixLength == Constants.SCHEMA_NORMALIZED_VALUE.length() && 315 featureId.endsWith(Constants.SCHEMA_NORMALIZED_VALUE)) { 316 return; 317 } 318 if (suffixLength == Constants.SCHEMA_ELEMENT_DEFAULT.length() && 321 featureId.endsWith(Constants.SCHEMA_ELEMENT_DEFAULT)) { 322 return; 323 } 324 } 325 326 330 super.checkFeature(featureId); 331 332 } 334 347 protected void checkProperty(String propertyId) 348 throws XMLConfigurationException { 349 350 354 if (propertyId.startsWith(Constants.XERCES_PROPERTY_PREFIX)) { 355 final int suffixLength = propertyId.length() - Constants.XERCES_PROPERTY_PREFIX.length(); 356 357 if (suffixLength == Constants.SCHEMA_LOCATION.length() && 358 propertyId.endsWith(Constants.SCHEMA_LOCATION)) { 359 return; 360 } 361 if (suffixLength == Constants.SCHEMA_NONS_LOCATION.length() && 362 propertyId.endsWith(Constants.SCHEMA_NONS_LOCATION)) { 363 return; 364 } 365 } 366 367 if (propertyId.startsWith(Constants.JAXP_PROPERTY_PREFIX)) { 368 final int suffixLength = propertyId.length() - Constants.JAXP_PROPERTY_PREFIX.length(); 369 370 if (suffixLength == Constants.SCHEMA_SOURCE.length() && 371 propertyId.endsWith(Constants.SCHEMA_SOURCE)) { 372 return; 373 } 374 } 375 376 380 super.checkProperty(propertyId); 381 382 } 384 } | Popular Tags |