50 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter; |
50 import com.sun.org.apache.xerces.internal.impl.xs.XSMessageFormatter; |
51 import com.sun.org.apache.xerces.internal.util.FeatureState; |
51 import com.sun.org.apache.xerces.internal.util.FeatureState; |
52 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings; |
52 import com.sun.org.apache.xerces.internal.util.ParserConfigurationSettings; |
53 import com.sun.org.apache.xerces.internal.util.PropertyState; |
53 import com.sun.org.apache.xerces.internal.util.PropertyState; |
54 import com.sun.org.apache.xerces.internal.util.SymbolTable; |
54 import com.sun.org.apache.xerces.internal.util.SymbolTable; |
55 import com.sun.org.apache.xerces.internal.utils.XMLSecurityManager; |
|
56 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; |
55 import com.sun.org.apache.xerces.internal.utils.XMLSecurityPropertyManager; |
57 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; |
56 import com.sun.org.apache.xerces.internal.xni.XMLDTDContentModelHandler; |
58 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler; |
57 import com.sun.org.apache.xerces.internal.xni.XMLDTDHandler; |
59 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler; |
58 import com.sun.org.apache.xerces.internal.xni.XMLDocumentHandler; |
60 import com.sun.org.apache.xerces.internal.xni.XMLLocator; |
59 import com.sun.org.apache.xerces.internal.xni.XMLLocator; |
164 |
163 |
165 /** Feature identifier: use grammar pool only */ |
164 /** Feature identifier: use grammar pool only */ |
166 protected static final String USE_GRAMMAR_POOL_ONLY = |
165 protected static final String USE_GRAMMAR_POOL_ONLY = |
167 Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; |
166 Constants.XERCES_FEATURE_PREFIX + Constants.USE_GRAMMAR_POOL_ONLY_FEATURE; |
168 |
167 |
169 // feature identifiers |
168 // feature identifiers |
170 |
169 |
171 /** Feature identifier: validation. */ |
170 /** Feature identifier: validation. */ |
172 protected static final String VALIDATION = |
171 protected static final String VALIDATION = |
173 Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE; |
172 Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE; |
174 |
173 |
175 /** Feature identifier: namespaces. */ |
174 /** Feature identifier: namespaces. */ |
176 protected static final String NAMESPACES = |
175 protected static final String NAMESPACES = |
177 Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE; |
176 Constants.SAX_FEATURE_PREFIX + Constants.NAMESPACES_FEATURE; |
178 |
177 |
179 /** Feature identifier: external general entities. */ |
178 /** Feature identifier: external general entities. */ |
180 protected static final String EXTERNAL_GENERAL_ENTITIES = |
179 protected static final String EXTERNAL_GENERAL_ENTITIES = |
181 Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE; |
180 Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_GENERAL_ENTITIES_FEATURE; |
182 |
181 |
183 /** Feature identifier: external parameter entities. */ |
182 /** Feature identifier: external parameter entities. */ |
184 protected static final String EXTERNAL_PARAMETER_ENTITIES = |
183 protected static final String EXTERNAL_PARAMETER_ENTITIES = |
185 Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE; |
184 Constants.SAX_FEATURE_PREFIX + Constants.EXTERNAL_PARAMETER_ENTITIES_FEATURE; |
186 |
185 |
187 /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ |
186 /** Feature identifier: whether to ignore xsi:type attributes until a global element declaration is encountered */ |
188 protected static final String IGNORE_XSI_TYPE = |
187 protected static final String IGNORE_XSI_TYPE = |
189 Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; |
188 Constants.XERCES_FEATURE_PREFIX + Constants.IGNORE_XSI_TYPE_FEATURE; |
190 |
189 |
191 /** Feature identifier: whether to ignore ID/IDREF errors */ |
190 /** Feature identifier: whether to ignore ID/IDREF errors */ |
192 protected static final String ID_IDREF_CHECKING = |
191 protected static final String ID_IDREF_CHECKING = |
193 Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; |
192 Constants.XERCES_FEATURE_PREFIX + Constants.ID_IDREF_CHECKING_FEATURE; |
194 |
193 |
195 /** Feature identifier: whether to ignore unparsed entity errors */ |
194 /** Feature identifier: whether to ignore unparsed entity errors */ |
196 protected static final String UNPARSED_ENTITY_CHECKING = |
195 protected static final String UNPARSED_ENTITY_CHECKING = |
197 Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; |
196 Constants.XERCES_FEATURE_PREFIX + Constants.UNPARSED_ENTITY_CHECKING_FEATURE; |
198 |
197 |
199 /** Feature identifier: whether to ignore identity constraint errors */ |
198 /** Feature identifier: whether to ignore identity constraint errors */ |
200 protected static final String IDENTITY_CONSTRAINT_CHECKING = |
199 protected static final String IDENTITY_CONSTRAINT_CHECKING = |
201 Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; |
200 Constants.XERCES_FEATURE_PREFIX + Constants.IDC_CHECKING_FEATURE; |
202 |
201 |
203 // property identifiers |
202 // property identifiers |
204 |
203 |
205 |
204 /** Property identifier: xml string. */ |
206 /** Property identifier: xml string. */ |
205 protected static final String XML_STRING = |
207 protected static final String XML_STRING = |
206 Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY; |
208 Constants.SAX_PROPERTY_PREFIX + Constants.XML_STRING_PROPERTY; |
207 |
209 |
208 /** Property identifier: symbol table. */ |
210 /** Property identifier: symbol table. */ |
209 protected static final String SYMBOL_TABLE = |
211 protected static final String SYMBOL_TABLE = |
210 Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY; |
212 Constants.XERCES_PROPERTY_PREFIX + Constants.SYMBOL_TABLE_PROPERTY; |
211 |
213 |
212 /** Property identifier: error handler. */ |
214 /** Property identifier: error handler. */ |
213 protected static final String ERROR_HANDLER = |
215 protected static final String ERROR_HANDLER = |
214 Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY; |
216 Constants.XERCES_PROPERTY_PREFIX + Constants.ERROR_HANDLER_PROPERTY; |
215 |
217 |
216 /** Property identifier: entity resolver. */ |
218 /** Property identifier: entity resolver. */ |
217 protected static final String ENTITY_RESOLVER = |
219 protected static final String ENTITY_RESOLVER = |
218 Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY; |
220 Constants.XERCES_PROPERTY_PREFIX + Constants.ENTITY_RESOLVER_PROPERTY; |
|
221 |
|
222 |
219 |
223 /** Property identifier: XML Schema validator. */ |
220 /** Property identifier: XML Schema validator. */ |
224 protected static final String SCHEMA_VALIDATOR = |
221 protected static final String SCHEMA_VALIDATOR = |
225 Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY; |
222 Constants.XERCES_PROPERTY_PREFIX + Constants.SCHEMA_VALIDATOR_PROPERTY; |
226 |
223 |
311 |
306 |
312 // |
307 // |
313 // Data |
308 // Data |
314 // |
309 // |
315 |
310 |
316 protected SymbolTable fSymbolTable; |
311 protected SymbolTable fSymbolTable; |
317 protected XMLInputSource fInputSource; |
312 protected XMLInputSource fInputSource; |
318 protected ValidationManager fValidationManager; |
313 protected ValidationManager fValidationManager; |
319 protected XMLVersionDetector fVersionDetector; |
314 protected XMLVersionDetector fVersionDetector; |
320 protected XMLLocator fLocator; |
315 protected XMLLocator fLocator; |
321 protected Locale fLocale; |
316 protected Locale fLocale; |
322 |
317 |
323 /** XML 1.0 Components. */ |
318 /** XML 1.0 Components. */ |
324 protected ArrayList fComponents; |
319 protected ArrayList<XMLComponent> fComponents; |
325 |
320 |
326 /** XML 1.1. Components. */ |
321 /** XML 1.1. Components. */ |
327 protected ArrayList fXML11Components = null; |
322 protected ArrayList<XMLComponent> fXML11Components = null; |
328 |
323 |
329 /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */ |
324 /** Common components: XMLEntityManager, XMLErrorReporter, XMLSchemaValidator */ |
330 protected ArrayList fCommonComponents = null; |
325 protected ArrayList<XMLComponent> fCommonComponents = null; |
331 |
326 |
332 /** The document handler. */ |
327 /** The document handler. */ |
333 protected XMLDocumentHandler fDocumentHandler; |
328 protected XMLDocumentHandler fDocumentHandler; |
334 |
329 |
335 /** The DTD handler. */ |
330 /** The DTD handler. */ |
336 protected XMLDTDHandler fDTDHandler; |
331 protected XMLDTDHandler fDTDHandler; |
337 |
332 |
338 /** The DTD content model handler. */ |
333 /** The DTD content model handler. */ |
339 protected XMLDTDContentModelHandler fDTDContentModelHandler; |
334 protected XMLDTDContentModelHandler fDTDContentModelHandler; |
340 |
335 |
341 /** Last component in the document pipeline */ |
336 /** Last component in the document pipeline */ |
342 protected XMLDocumentSource fLastComponent; |
337 protected XMLDocumentSource fLastComponent; |
343 |
338 |
344 /** |
339 /** |
345 * True if a parse is in progress. This state is needed because |
340 * True if a parse is in progress. This state is needed because |
346 * some features/properties cannot be set while parsing (e.g. |
341 * some features/properties cannot be set while parsing (e.g. |
347 * validation and namespaces). |
342 * validation and namespaces). |
475 |
470 |
476 super(parentSettings); |
471 super(parentSettings); |
477 |
472 |
478 // create a vector to hold all the components in use |
473 // create a vector to hold all the components in use |
479 // XML 1.0 specialized components |
474 // XML 1.0 specialized components |
480 fComponents = new ArrayList(); |
475 fComponents = new ArrayList<>(); |
481 // XML 1.1 specialized components |
476 // XML 1.1 specialized components |
482 fXML11Components = new ArrayList(); |
477 fXML11Components = new ArrayList<>(); |
483 // Common components for XML 1.1. and XML 1.0 |
478 // Common components for XML 1.1. and XML 1.0 |
484 fCommonComponents = new ArrayList(); |
479 fCommonComponents = new ArrayList<>(); |
485 |
480 |
486 // create table for features and properties |
481 // create table for features and properties |
487 fFeatures = new HashMap(); |
482 fFeatures = new HashMap<>(); |
488 fProperties = new HashMap(); |
483 fProperties = new HashMap<>(); |
489 |
484 |
490 // add default recognized features |
485 // add default recognized features |
491 final String[] recognizedFeatures = |
486 final String[] recognizedFeatures = |
492 { |
487 { |
493 CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl |
488 CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl |
578 if (fGrammarPool != null) { |
573 if (fGrammarPool != null) { |
579 fProperties.put(XMLGRAMMAR_POOL, fGrammarPool); |
574 fProperties.put(XMLGRAMMAR_POOL, fGrammarPool); |
580 } |
575 } |
581 |
576 |
582 fEntityManager = new XMLEntityManager(); |
577 fEntityManager = new XMLEntityManager(); |
583 fProperties.put(ENTITY_MANAGER, fEntityManager); |
578 fProperties.put(ENTITY_MANAGER, fEntityManager); |
584 addCommonComponent(fEntityManager); |
579 addCommonComponent(fEntityManager); |
585 |
580 |
586 fErrorReporter = new XMLErrorReporter(); |
581 fErrorReporter = new XMLErrorReporter(); |
587 fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner()); |
582 fErrorReporter.setDocumentLocator(fEntityManager.getEntityScanner()); |
588 fProperties.put(ERROR_REPORTER, fErrorReporter); |
583 fProperties.put(ERROR_REPORTER, fErrorReporter); |
589 addCommonComponent(fErrorReporter); |
584 addCommonComponent(fErrorReporter); |
590 |
585 |
591 fNamespaceScanner = new XMLNSDocumentScannerImpl(); |
586 fNamespaceScanner = new XMLNSDocumentScannerImpl(); |
592 fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner); |
587 fProperties.put(DOCUMENT_SCANNER, fNamespaceScanner); |
593 addComponent((XMLComponent) fNamespaceScanner); |
588 addComponent((XMLComponent) fNamespaceScanner); |
594 |
589 |
595 fDTDScanner = new XMLDTDScannerImpl(); |
590 fDTDScanner = new XMLDTDScannerImpl(); |
596 fProperties.put(DTD_SCANNER, fDTDScanner); |
591 fProperties.put(DTD_SCANNER, fDTDScanner); |
597 addComponent((XMLComponent) fDTDScanner); |
592 addComponent((XMLComponent) fDTDScanner); |
598 |
593 |
599 fDTDProcessor = new XMLDTDProcessor(); |
594 fDTDProcessor = new XMLDTDProcessor(); |
600 fProperties.put(DTD_PROCESSOR, fDTDProcessor); |
595 fProperties.put(DTD_PROCESSOR, fDTDProcessor); |
601 addComponent((XMLComponent) fDTDProcessor); |
596 addComponent((XMLComponent) fDTDProcessor); |
602 |
597 |
603 fDTDValidator = new XMLNSDTDValidator(); |
598 fDTDValidator = new XMLNSDTDValidator(); |
604 fProperties.put(DTD_VALIDATOR, fDTDValidator); |
599 fProperties.put(DTD_VALIDATOR, fDTDValidator); |
605 addComponent(fDTDValidator); |
600 addComponent(fDTDValidator); |
606 |
601 |
607 fDatatypeValidatorFactory = DTDDVFactory.getInstance(); |
602 fDatatypeValidatorFactory = DTDDVFactory.getInstance(); |
608 fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory); |
603 fProperties.put(DATATYPE_VALIDATOR_FACTORY, fDatatypeValidatorFactory); |
609 |
604 |
610 fValidationManager = new ValidationManager(); |
605 fValidationManager = new ValidationManager(); |
611 fProperties.put(VALIDATION_MANAGER, fValidationManager); |
606 fProperties.put(VALIDATION_MANAGER, fValidationManager); |
612 |
607 |
613 fVersionDetector = new XMLVersionDetector(); |
608 fVersionDetector = new XMLVersionDetector(); |
614 |
609 |
615 // add message formatters |
610 // add message formatters |
616 if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { |
611 if (fErrorReporter.getMessageFormatter(XMLMessageFormatter.XML_DOMAIN) == null) { |
933 throws XMLConfigurationException { |
928 throws XMLConfigurationException { |
934 fConfigUpdated = true; |
929 fConfigUpdated = true; |
935 // forward to every XML 1.0 component |
930 // forward to every XML 1.0 component |
936 int count = fComponents.size(); |
931 int count = fComponents.size(); |
937 for (int i = 0; i < count; i++) { |
932 for (int i = 0; i < count; i++) { |
938 XMLComponent c = (XMLComponent) fComponents.get(i); |
933 XMLComponent c = fComponents.get(i); |
939 c.setFeature(featureId, state); |
934 c.setFeature(featureId, state); |
940 } |
935 } |
941 // forward it to common components |
936 // forward it to common components |
942 count = fCommonComponents.size(); |
937 count = fCommonComponents.size(); |
943 for (int i = 0; i < count; i++) { |
938 for (int i = 0; i < count; i++) { |
944 XMLComponent c = (XMLComponent) fCommonComponents.get(i); |
939 XMLComponent c = fCommonComponents.get(i); |
945 c.setFeature(featureId, state); |
940 c.setFeature(featureId, state); |
946 } |
941 } |
947 |
942 |
948 // forward to every XML 1.1 component |
943 // forward to every XML 1.1 component |
949 count = fXML11Components.size(); |
944 count = fXML11Components.size(); |
950 for (int i = 0; i < count; i++) { |
945 for (int i = 0; i < count; i++) { |
951 XMLComponent c = (XMLComponent) fXML11Components.get(i); |
946 XMLComponent c = fXML11Components.get(i); |
952 try{ |
947 try{ |
953 c.setFeature(featureId, state); |
948 c.setFeature(featureId, state); |
954 } |
949 } |
955 catch (Exception e){ |
950 catch (Exception e){ |
956 // no op |
951 // no op |
994 setLocale((Locale) value); |
989 setLocale((Locale) value); |
995 } |
990 } |
996 // forward to every XML 1.0 component |
991 // forward to every XML 1.0 component |
997 int count = fComponents.size(); |
992 int count = fComponents.size(); |
998 for (int i = 0; i < count; i++) { |
993 for (int i = 0; i < count; i++) { |
999 XMLComponent c = (XMLComponent) fComponents.get(i); |
994 XMLComponent c = fComponents.get(i); |
1000 c.setProperty(propertyId, value); |
995 c.setProperty(propertyId, value); |
1001 } |
996 } |
1002 // forward it to every common Component |
997 // forward it to every common Component |
1003 count = fCommonComponents.size(); |
998 count = fCommonComponents.size(); |
1004 for (int i = 0; i < count; i++) { |
999 for (int i = 0; i < count; i++) { |
1005 XMLComponent c = (XMLComponent) fCommonComponents.get(i); |
1000 XMLComponent c = fCommonComponents.get(i); |
1006 c.setProperty(propertyId, value); |
1001 c.setProperty(propertyId, value); |
1007 } |
1002 } |
1008 // forward it to every XML 1.1 component |
1003 // forward it to every XML 1.1 component |
1009 count = fXML11Components.size(); |
1004 count = fXML11Components.size(); |
1010 for (int i = 0; i < count; i++) { |
1005 for (int i = 0; i < count; i++) { |
1011 XMLComponent c = (XMLComponent) fXML11Components.get(i); |
1006 XMLComponent c = fXML11Components.get(i); |
1012 try{ |
1007 try{ |
1013 c.setProperty(propertyId, value); |
1008 c.setProperty(propertyId, value); |
1014 } |
1009 } |
1015 catch (Exception e){ |
1010 catch (Exception e){ |
1016 // ignore it |
1011 // ignore it |