1 /*
2 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. 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.parsers;
22
489 {
490 CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
491 VALIDATION,
492 NAMESPACES,
493 NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
494 GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
495 HONOUR_ALL_SCHEMALOCATIONS, IGNORE_XSI_TYPE,
496 ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING,
497 UNPARSED_ENTITY_CHECKING,
498 NAMESPACE_GROWTH, TOLERATE_DUPLICATES,
499 USE_GRAMMAR_POOL_ONLY,
500 // NOTE: These shouldn't really be here but since the XML Schema
501 // validator is constructed dynamically, its recognized
502 // features might not have been set and it would cause a
503 // not-recognized exception to be thrown. -Ac
504 XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
505 EXTERNAL_GENERAL_ENTITIES,
506 EXTERNAL_PARAMETER_ENTITIES,
507 PARSER_SETTINGS,
508 XMLConstants.FEATURE_SECURE_PROCESSING,
509 XMLConstants.USE_CATALOG
510 };
511 addRecognizedFeatures(recognizedFeatures);
512 // set state for default features
513 fFeatures.put(VALIDATION, Boolean.FALSE);
514 fFeatures.put(NAMESPACES, Boolean.TRUE);
515 fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
516 fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
517 fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
518 fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
519 fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
520 fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
521 fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
522 fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
523 fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
524 fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
525 fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE);
526 fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
527 fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);
528 fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE);
529 fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE);
530 fFeatures.put(TOLERATE_DUPLICATES, Boolean.FALSE);
531 fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
532 fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
533 fFeatures.put(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
534 fFeatures.put(XMLConstants.USE_CATALOG, JdkXmlUtils.USE_CATALOG_DEFAULT);
535
536 // add default recognized properties
537 final String[] recognizedProperties =
538 {
539 SYMBOL_TABLE,
540 ERROR_HANDLER,
541 ENTITY_RESOLVER,
542 ERROR_REPORTER,
543 ENTITY_MANAGER,
544 DOCUMENT_SCANNER,
545 DTD_SCANNER,
546 DTD_PROCESSOR,
547 DTD_VALIDATOR,
548 DATATYPE_VALIDATOR_FACTORY,
549 VALIDATION_MANAGER,
550 SCHEMA_VALIDATOR,
551 XML_STRING,
552 XMLGRAMMAR_POOL,
553 JAXP_SCHEMA_SOURCE,
554 JAXP_SCHEMA_LANGUAGE,
1568 fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
1569
1570 // setup XML 1.1 DTD pipeline
1571 fXML11DTDScanner = new XML11DTDScannerImpl();
1572 addXML11Component(fXML11DTDScanner);
1573 fXML11DTDProcessor = new XML11DTDProcessor();
1574 addXML11Component(fXML11DTDProcessor);
1575
1576 // setup XML 1.1. document pipeline - namespace aware
1577 fXML11NSDocScanner = new XML11NSDocumentScannerImpl();
1578 addXML11Component(fXML11NSDocScanner);
1579 fXML11NSDTDValidator = new XML11NSDTDValidator();
1580 addXML11Component(fXML11NSDTDValidator);
1581
1582 f11Initialized = true;
1583 }
1584 }
1585
1586
1587 /**
1588 * Reset the symbol table if it wasn't provided during construction
1589 * and its not the first time when parse is called after initialization
1590 */
1591 private void resetSymbolTable() {
1592 if (!fSymbolTableProvided) {
1593 if (fSymbolTableJustInitialized) {
1594 // Skip symbol table reallocation for the first parsing process
1595 fSymbolTableJustInitialized = false;
1596 } else {
1597 fSymbolTable = new SymbolTable();
1598 fProperties.put(SYMBOL_TABLE, fSymbolTable);
1599 }
1600 }
1601 }
1602
1603 /**
1604 * Returns the state of a feature. This method calls getFeature()
1605 * on ParserConfigurationSettings, bypassing getFeature() on this
1606 * class.
1607 */
1608 FeatureState getFeatureState0(String featureId)
1609 throws XMLConfigurationException {
1610 return super.getFeatureState(featureId);
1611 }
1612
|
1 /*
2 * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved.
3 */
4 /*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements. See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License. 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.parsers;
22
489 {
490 CONTINUE_AFTER_FATAL_ERROR, LOAD_EXTERNAL_DTD, // from XMLDTDScannerImpl
491 VALIDATION,
492 NAMESPACES,
493 NORMALIZE_DATA, SCHEMA_ELEMENT_DEFAULT, SCHEMA_AUGMENT_PSVI,
494 GENERATE_SYNTHETIC_ANNOTATIONS, VALIDATE_ANNOTATIONS,
495 HONOUR_ALL_SCHEMALOCATIONS, IGNORE_XSI_TYPE,
496 ID_IDREF_CHECKING, IDENTITY_CONSTRAINT_CHECKING,
497 UNPARSED_ENTITY_CHECKING,
498 NAMESPACE_GROWTH, TOLERATE_DUPLICATES,
499 USE_GRAMMAR_POOL_ONLY,
500 // NOTE: These shouldn't really be here but since the XML Schema
501 // validator is constructed dynamically, its recognized
502 // features might not have been set and it would cause a
503 // not-recognized exception to be thrown. -Ac
504 XMLSCHEMA_VALIDATION, XMLSCHEMA_FULL_CHECKING,
505 EXTERNAL_GENERAL_ENTITIES,
506 EXTERNAL_PARAMETER_ENTITIES,
507 PARSER_SETTINGS,
508 XMLConstants.FEATURE_SECURE_PROCESSING,
509 XMLConstants.USE_CATALOG,
510 JdkXmlUtils.RESET_SYMBOL_TABLE
511 };
512 addRecognizedFeatures(recognizedFeatures);
513 // set state for default features
514 fFeatures.put(VALIDATION, Boolean.FALSE);
515 fFeatures.put(NAMESPACES, Boolean.TRUE);
516 fFeatures.put(EXTERNAL_GENERAL_ENTITIES, Boolean.TRUE);
517 fFeatures.put(EXTERNAL_PARAMETER_ENTITIES, Boolean.TRUE);
518 fFeatures.put(CONTINUE_AFTER_FATAL_ERROR, Boolean.FALSE);
519 fFeatures.put(LOAD_EXTERNAL_DTD, Boolean.TRUE);
520 fFeatures.put(SCHEMA_ELEMENT_DEFAULT, Boolean.TRUE);
521 fFeatures.put(NORMALIZE_DATA, Boolean.TRUE);
522 fFeatures.put(SCHEMA_AUGMENT_PSVI, Boolean.TRUE);
523 fFeatures.put(GENERATE_SYNTHETIC_ANNOTATIONS, Boolean.FALSE);
524 fFeatures.put(VALIDATE_ANNOTATIONS, Boolean.FALSE);
525 fFeatures.put(HONOUR_ALL_SCHEMALOCATIONS, Boolean.FALSE);
526 fFeatures.put(IGNORE_XSI_TYPE, Boolean.FALSE);
527 fFeatures.put(ID_IDREF_CHECKING, Boolean.TRUE);
528 fFeatures.put(IDENTITY_CONSTRAINT_CHECKING, Boolean.TRUE);
529 fFeatures.put(UNPARSED_ENTITY_CHECKING, Boolean.TRUE);
530 fFeatures.put(NAMESPACE_GROWTH, Boolean.FALSE);
531 fFeatures.put(TOLERATE_DUPLICATES, Boolean.FALSE);
532 fFeatures.put(USE_GRAMMAR_POOL_ONLY, Boolean.FALSE);
533 fFeatures.put(PARSER_SETTINGS, Boolean.TRUE);
534 fFeatures.put(XMLConstants.FEATURE_SECURE_PROCESSING, Boolean.TRUE);
535 fFeatures.put(XMLConstants.USE_CATALOG, JdkXmlUtils.USE_CATALOG_DEFAULT);
536 fFeatures.put(JdkXmlUtils.RESET_SYMBOL_TABLE, JdkXmlUtils.RESET_SYMBOL_TABLE_DEFAULT);
537
538 // add default recognized properties
539 final String[] recognizedProperties =
540 {
541 SYMBOL_TABLE,
542 ERROR_HANDLER,
543 ENTITY_RESOLVER,
544 ERROR_REPORTER,
545 ENTITY_MANAGER,
546 DOCUMENT_SCANNER,
547 DTD_SCANNER,
548 DTD_PROCESSOR,
549 DTD_VALIDATOR,
550 DATATYPE_VALIDATOR_FACTORY,
551 VALIDATION_MANAGER,
552 SCHEMA_VALIDATOR,
553 XML_STRING,
554 XMLGRAMMAR_POOL,
555 JAXP_SCHEMA_SOURCE,
556 JAXP_SCHEMA_LANGUAGE,
1570 fXML11DatatypeFactory = DTDDVFactory.getInstance(XML11_DATATYPE_VALIDATOR_FACTORY);
1571
1572 // setup XML 1.1 DTD pipeline
1573 fXML11DTDScanner = new XML11DTDScannerImpl();
1574 addXML11Component(fXML11DTDScanner);
1575 fXML11DTDProcessor = new XML11DTDProcessor();
1576 addXML11Component(fXML11DTDProcessor);
1577
1578 // setup XML 1.1. document pipeline - namespace aware
1579 fXML11NSDocScanner = new XML11NSDocumentScannerImpl();
1580 addXML11Component(fXML11NSDocScanner);
1581 fXML11NSDTDValidator = new XML11NSDTDValidator();
1582 addXML11Component(fXML11NSDTDValidator);
1583
1584 f11Initialized = true;
1585 }
1586 }
1587
1588
1589 /**
1590 * Reset the symbol table if it wasn't provided during construction,
1591 * its not the first time when parse is called after initialization
1592 * and RESET_SYMBOL_TABLE feature is set to true
1593 */
1594 private void resetSymbolTable() {
1595 if (fFeatures.get(JdkXmlUtils.RESET_SYMBOL_TABLE) && !fSymbolTableProvided) {
1596 if (fSymbolTableJustInitialized) {
1597 // Skip symbol table reallocation for the first parsing process
1598 fSymbolTableJustInitialized = false;
1599 } else {
1600 fSymbolTable = new SymbolTable();
1601 fProperties.put(SYMBOL_TABLE, fSymbolTable);
1602 }
1603 }
1604 }
1605
1606 /**
1607 * Returns the state of a feature. This method calls getFeature()
1608 * on ParserConfigurationSettings, bypassing getFeature() on this
1609 * class.
1610 */
1611 FeatureState getFeatureState0(String featureId)
1612 throws XMLConfigurationException {
1613 return super.getFeatureState(featureId);
1614 }
1615
|