1 /* 2 * Copyright (c) 2009, 2014, 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.impl; 22 23 import com.sun.org.apache.xerces.internal.utils.SecuritySupport; 24 import java.util.Enumeration; 25 import java.util.NoSuchElementException; 26 27 /** 28 * Commonly used constants. 29 * 30 * @xerces.internal 31 * 32 * @author Andy Clark, IBM 33 * 34 */ 35 public final class Constants { 36 37 // 38 // Constants 39 // 40 // Schema Types: 41 public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern(); 42 public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern(); 43 44 // Schema Versions: 45 public static final String W3C_XML_SCHEMA10_NS_URI = "http://www.w3.org/XML/XMLSchema/v1.0".intern(); 46 47 // Schema features 48 public static final String SUN_SCHEMA_FEATURE_PREFIX = "http://java.sun.com/xml/schema/features/"; 49 public static final String SUN_REPORT_IGNORED_ELEMENT_CONTENT_WHITESPACE = "report-ignored-element-content-whitespace"; 50 51 //stax properties 52 53 public static final String ZEPHYR_PROPERTY_PREFIX = "http://java.sun.com/xml/stream/properties/" ; 54 public static final String STAX_PROPERTIES = "stax-properties" ; 55 public static final String STAX_ENTITY_RESOLVER_PROPERTY = "internal/stax-entity-resolver"; 56 public static final String STAX_REPORT_CDATA_EVENT = "report-cdata-event"; 57 public static final String READER_IN_DEFINED_STATE = ZEPHYR_PROPERTY_PREFIX + "reader-in-defined-state" ; 58 public static final String ADD_NAMESPACE_DECL_AS_ATTRIBUTE = "add-namespacedecl-as-attrbiute"; 59 public static final String ESCAPE_CHARACTERS = "escapeCharacters"; 60 public static final String REUSE_INSTANCE = "reuse-instance" ; 61 62 //DOM properties 63 public static final String SUN_DOM_PROPERTY_PREFIX = "http://java.sun.com/xml/dom/properties/" ; 64 public static final String SUN_DOM_ANCESTOR_CHECCK = "ancestor-check"; 65 66 /** 67 * If true, ignore DOCTYPE declaration as if it wasn't present at all. 68 * Note that this is a violation of the XML recommendation. 69 * The full property name is prefixed by {@link #ZEPHYR_PROPERTY_PREFIX}. 70 */ 71 public static final String IGNORE_EXTERNAL_DTD = "ignore-external-dtd"; 72 73 // sax features 74 75 /** SAX feature prefix ("http://xml.org/sax/features/"). */ 76 public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/"; 77 78 public static final String NAMESPACES_FEATURE = "namespaces"; 79 80 /** Namespace prefixes feature ("namespace-prefixes"). */ 81 public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes"; 82 83 /** String interning feature ("string-interning"). */ 84 public static final String STRING_INTERNING_FEATURE = "string-interning"; 85 86 /** Validation feature ("validation"). */ 87 public static final String VALIDATION_FEATURE = "validation"; 88 89 /** External general entities feature ("external-general-entities "). */ 90 public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities"; 91 92 /** External parameter entities feature ("external-parameter-entities "). */ 93 public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities"; 94 95 /** Lexical handler parameter entities feature ("lexical-handler/parameter-entities"). */ 96 public static final String LEXICAL_HANDLER_PARAMETER_ENTITIES_FEATURE = "lexical-handler/parameter-entities"; 97 98 /** Is standalone feature ("is-standalone"). */ 99 public static final String IS_STANDALONE_FEATURE = "is-standalone"; 100 101 /** Resolve DTD URIs feature ("resolve-dtd-uris"). */ 102 public static final String RESOLVE_DTD_URIS_FEATURE = "resolve-dtd-uris"; 103 104 /** Use Attributes2 feature ("use-attributes2"). */ 105 public static final String USE_ATTRIBUTES2_FEATURE = "use-attributes2"; 106 107 /** Use Locator2 feature ("use-locator2"). */ 108 public static final String USE_LOCATOR2_FEATURE = "use-locator2"; 109 110 /** Use EntityResolver2 feature ("use-entity-resolver2"). */ 111 public static final String USE_ENTITY_RESOLVER2_FEATURE = "use-entity-resolver2"; 112 113 /** Unicode normalization checking feature ("unicode-normalization-checking"). */ 114 public static final String UNICODE_NORMALIZATION_CHECKING_FEATURE = "unicode-normalization-checking"; 115 116 /** xmlns URIs feature ("xmlns-uris"). */ 117 public static final String XMLNS_URIS_FEATURE = "xmlns-uris"; 118 119 /** XML 1.1 feature ("xml-1.1"). */ 120 public static final String XML_11_FEATURE = "xml-1.1"; 121 122 /** Allow unparsed entity and notation declaration events to be sent after the end DTD event ("allow-dtd-events-after-endDTD") */ 123 public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD"; 124 125 // sax properties 126 127 /** SAX property prefix ("http://xml.org/sax/properties/"). */ 128 public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/"; 129 130 /** Declaration handler property ("declaration-handler"). */ 131 public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler"; 132 133 /** Lexical handler property ("lexical-handler"). */ 134 public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler"; 135 136 /** DOM node property ("dom-node"). */ 137 public static final String DOM_NODE_PROPERTY = "dom-node"; 138 139 /** XML string property ("xml-string"). */ 140 public static final String XML_STRING_PROPERTY = "xml-string"; 141 142 public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing"; 143 144 // Oracle Feature: 145 /** 146 * <p>Use Service Mechanism</p> 147 * 148 * <ul> 149 * <li> 150 * {@code true} instruct an object to use service mechanism to 151 * find a service implementation. This is the default behavior. 152 * </li> 153 * <li> 154 * {@code false} instruct an object to skip service mechanism and 155 * use the default implementation for that service. 156 * </li> 157 * </ul> 158 */ 159 public static final String ORACLE_FEATURE_SERVICE_MECHANISM = "http://www.oracle.com/feature/use-service-mechanism"; 160 161 /** Document XML version property ("document-xml-version"). */ 162 public static final String DOCUMENT_XML_VERSION_PROPERTY = "document-xml-version"; 163 164 165 // 166 // JAXP properties 167 // 168 169 /** JAXP property prefix ("http://java.sun.com/xml/jaxp/properties/"). */ 170 public static final String JAXP_PROPERTY_PREFIX = 171 "http://java.sun.com/xml/jaxp/properties/"; 172 173 /** JAXP schemaSource property: when used internally may include DTD sources (DOM) */ 174 public static final String SCHEMA_SOURCE = "schemaSource"; 175 176 /** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */ 177 public static final String SCHEMA_LANGUAGE = "schemaLanguage"; 178 179 /** JAXP Standard property prefix ("http://javax.xml.XMLConstants/property/"). */ 180 public static final String JAXPAPI_PROPERTY_PREFIX = 181 "http://javax.xml.XMLConstants/property/"; 182 183 /** Oracle JAXP property prefix ("http://www.oracle.com/xml/jaxp/properties/"). */ 184 public static final String ORACLE_JAXP_PROPERTY_PREFIX = 185 "http://www.oracle.com/xml/jaxp/properties/"; 186 187 public static final String XML_SECURITY_PROPERTY_MANAGER = 188 ORACLE_JAXP_PROPERTY_PREFIX + "xmlSecurityPropertyManager"; 189 190 //System Properties corresponding to ACCESS_EXTERNAL_* properties 191 public static final String SP_ACCESS_EXTERNAL_DTD = "javax.xml.accessExternalDTD"; 192 public static final String SP_ACCESS_EXTERNAL_SCHEMA = "javax.xml.accessExternalSchema"; 193 //all access keyword 194 public static final String ACCESS_EXTERNAL_ALL = "all"; 195 196 /** 197 * Default value when FEATURE_SECURE_PROCESSING (FSP) is set to true 198 */ 199 public static final String EXTERNAL_ACCESS_DEFAULT_FSP = ""; 200 201 /** 202 * FEATURE_SECURE_PROCESSING (FSP) is true by default 203 */ 204 public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL; 205 206 /** 207 * Check if we're in jdk8 or above 208 */ 209 public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8); 210 211 // 212 // Implementation limits: corresponding System Properties of the above 213 // API properties 214 // 215 /** 216 * JDK entity expansion limit; Note that the existing system property 217 * "entityExpansionLimit" with no prefix is still observed 218 */ 219 public static final String JDK_ENTITY_EXPANSION_LIMIT = 220 ORACLE_JAXP_PROPERTY_PREFIX + "entityExpansionLimit"; 221 222 /** 223 * JDK element attribute limit; Note that the existing system property 224 * "elementAttributeLimit" with no prefix is still observed 225 */ 226 public static final String JDK_ELEMENT_ATTRIBUTE_LIMIT = 227 ORACLE_JAXP_PROPERTY_PREFIX + "elementAttributeLimit"; 228 229 /** 230 * JDK maxOccur limit; Note that the existing system property 231 * "maxOccurLimit" with no prefix is still observed 232 */ 233 public static final String JDK_MAX_OCCUR_LIMIT = 234 ORACLE_JAXP_PROPERTY_PREFIX + "maxOccurLimit"; 235 236 /** 237 * JDK total entity size limit 238 */ 239 public static final String JDK_TOTAL_ENTITY_SIZE_LIMIT = 240 ORACLE_JAXP_PROPERTY_PREFIX + "totalEntitySizeLimit"; 241 242 /** 243 * JDK maximum general entity size limit 244 */ 245 public static final String JDK_GENERAL_ENTITY_SIZE_LIMIT = 246 ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit"; 247 /** 248 * JDK maximum parameter entity size limit 249 */ 250 public static final String JDK_PARAMETER_ENTITY_SIZE_LIMIT = 251 ORACLE_JAXP_PROPERTY_PREFIX + "maxParameterEntitySizeLimit"; 252 /** 253 * JDK maximum XML name limit 254 */ 255 public static final String JDK_XML_NAME_LIMIT = 256 ORACLE_JAXP_PROPERTY_PREFIX + "maxXMLNameLimit"; 257 258 /** 259 * JDK maxElementDepth limit 260 */ 261 public static final String JDK_MAX_ELEMENT_DEPTH = 262 ORACLE_JAXP_PROPERTY_PREFIX + "maxElementDepth"; 263 264 /** 265 * JDK property to allow printing out information from the limit analyzer 266 */ 267 public static final String JDK_ENTITY_COUNT_INFO = 268 ORACLE_JAXP_PROPERTY_PREFIX + "getEntityCountInfo"; 269 270 // 271 // Implementation limits: API properties 272 // 273 /** 274 * JDK entity expansion limit; Note that the existing system property 275 * "entityExpansionLimit" with no prefix is still observed 276 */ 277 public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit"; 278 279 /** 280 * JDK element attribute limit; Note that the existing system property 281 * "elementAttributeLimit" with no prefix is still observed 282 */ 283 public static final String SP_ELEMENT_ATTRIBUTE_LIMIT = "jdk.xml.elementAttributeLimit"; 284 285 /** 286 * JDK maxOccur limit; Note that the existing system property 287 * "maxOccurLimit" with no prefix is still observed 288 */ 289 public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit"; 290 291 /** 292 * JDK total entity size limit 293 */ 294 public static final String SP_TOTAL_ENTITY_SIZE_LIMIT = "jdk.xml.totalEntitySizeLimit"; 295 296 /** 297 * JDK maximum general entity size limit 298 */ 299 public static final String SP_GENERAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit"; 300 /** 301 * JDK maximum parameter entity size limit 302 */ 303 public static final String SP_PARAMETER_ENTITY_SIZE_LIMIT = "jdk.xml.maxParameterEntitySizeLimit"; 304 /** 305 * JDK maximum XML name limit 306 */ 307 public static final String SP_XML_NAME_LIMIT = "jdk.xml.maxXMLNameLimit"; 308 309 /** 310 * JDK maxElementDepth limit 311 */ 312 public static final String SP_MAX_ELEMENT_DEPTH = "jdk.xml.maxElementDepth"; 313 314 //legacy System Properties 315 public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit"; 316 public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ; 317 public final static String MAX_OCCUR_LIMIT = "maxOccurLimit"; 318 319 /** 320 * A string "yes" that can be used for properties such as getEntityCountInfo 321 */ 322 public static final String JDK_YES = "yes"; 323 324 // 325 // DOM features 326 // 327 328 /** Comments feature ("include-comments"). */ 329 public static final String INCLUDE_COMMENTS_FEATURE = "include-comments"; 330 331 /** Create cdata nodes feature ("create-cdata-nodes"). */ 332 public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes"; 333 334 /** Feature id: load as infoset. */ 335 public static final String LOAD_AS_INFOSET = "load-as-infoset"; 336 337 338 // 339 // Constants: DOM Level 3 feature ids 340 // 341 342 public static final String DOM_CANONICAL_FORM = "canonical-form"; 343 public static final String DOM_CDATA_SECTIONS ="cdata-sections"; 344 345 public static final String DOM_COMMENTS = "comments"; 346 347 // REVISIT: this feature seems to have no effect for Xerces 348 349 public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = 350 "charset-overrides-xml-encoding"; 351 352 public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization"; 353 354 public static final String DOM_ENTITIES = "entities"; 355 public static final String DOM_INFOSET = "infoset"; 356 public static final String DOM_NAMESPACES = "namespaces"; 357 public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations"; 358 public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = 359 "supported-media-types-only"; 360 361 public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema"; 362 public static final String DOM_VALIDATE = "validate"; 363 public static final String DOM_ELEMENT_CONTENT_WHITESPACE = 364 "element-content-whitespace"; 365 366 // DOM Level 3 features defined in Core: 367 public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content"; 368 public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters"; 369 public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization"; 370 public static final String DOM_WELLFORMED = "well-formed"; 371 public static final String DOM_SPLIT_CDATA = "split-cdata-sections"; 372 373 // Load and Save 374 public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print"; 375 public static final String DOM_XMLDECL = "xml-declaration"; 376 public static final String DOM_UNKNOWNCHARS = "unknown-characters"; 377 public static final String DOM_CERTIFIED = "certified"; 378 public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype"; 379 public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations"; 380 381 // DOM Properties 382 public static final String DOM_RESOURCE_RESOLVER = "resource-resolver"; 383 public static final String DOM_ERROR_HANDLER = "error-handler"; 384 public static final String DOM_SCHEMA_TYPE = "schema-type"; 385 public static final String DOM_SCHEMA_LOCATION = "schema-location"; 386 public static final String DOM_ANCESTOR_CHECCK = "ancestor-check"; 387 // XSModel 388 public static final String DOM_PSVI = "psvi"; 389 390 391 // xerces features 392 393 /** Xerces features prefix ("http://apache.org/xml/features/"). */ 394 public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/"; 395 396 /** Schema validation feature ("validation/schema"). */ 397 public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema"; 398 399 /** Expose schema normalized values */ 400 public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value"; 401 402 /** Send schema default value via characters() */ 403 public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default"; 404 405 /** Schema full constraint checking ("validation/schema-full-checking"). */ 406 public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking"; 407 408 /** Augment Post-Schema-Validation-Infoset */ 409 public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi"; 410 411 /** Dynamic validation feature ("validation/dynamic"). */ 412 public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic"; 413 414 /** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */ 415 public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef"; 416 417 /** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */ 418 public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef"; 419 420 /** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */ 421 public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef"; 422 423 /** Allow Java encoding names feature ("allow-java-encodings"). */ 424 public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings"; 425 426 /** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */ 427 public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl"; 428 429 /** Continue after fatal error feature ("continue-after-fatal-error"). */ 430 public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error"; 431 432 /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */ 433 public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar"; 434 435 /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */ 436 public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd"; 437 438 /** Defer node expansion feature ("dom/defer-node-expansion"). */ 439 public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion"; 440 441 /** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */ 442 public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes"; 443 444 /** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */ 445 public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace"; 446 447 /** Default attribute values feature ("validation/default-attribute-values"). */ 448 public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values"; 449 450 /** Validate content models feature ("validation/validate-content-models"). */ 451 public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models"; 452 453 /** Validate datatypes feature ("validation/validate-datatypes"). */ 454 public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes"; 455 456 /** Balance syntax trees feature ("validation/balance-syntax-trees"). */ 457 public static final String BALANCE_SYNTAX_TREES = "validation/balance-syntax-trees"; 458 459 /** Notify character references feature (scanner/notify-char-refs"). */ 460 public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs"; 461 462 /** Notify built-in (&amp;, etc.) references feature (scanner/notify-builtin-refs"). */ 463 public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs"; 464 465 /** Standard URI conformant feature ("standard-uri-conformant"). */ 466 public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant"; 467 468 /** Generate synthetic annotations feature ("generate-synthetic-annotations"). */ 469 public static final String GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE = "generate-synthetic-annotations"; 470 471 /** Validate annotations feature ("validate-annotations"). */ 472 public static final String VALIDATE_ANNOTATIONS_FEATURE = "validate-annotations"; 473 474 475 /** Honour all schemaLocations feature ("honour-all-schemaLocations"). */ 476 public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations"; 477 478 /** Namespace growth feature ("namespace-growth"). */ 479 public static final String NAMESPACE_GROWTH_FEATURE = "namespace-growth"; 480 481 /** Tolerate duplicates feature ("internal/tolerate-duplicates"). */ 482 public static final String TOLERATE_DUPLICATES_FEATURE = "internal/tolerate-duplicates"; 483 484 /** XInclude processing feature ("xinclude"). */ 485 public static final String XINCLUDE_FEATURE = "xinclude"; 486 487 /** XInclude fixup base URIs feature ("xinclude/fixup-base-uris"). */ 488 public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris"; 489 490 /** XInclude fixup language feature ("xinclude/fixup-language"). */ 491 public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language"; 492 493 /** 494 * Feature to ignore xsi:type attributes on elements during validation, 495 * until a global element declaration is found. ("validation/schema/ignore-xsi-type-until-elemdecl") 496 * If this feature is on when validating a document, then beginning at the validation root 497 * element, xsi:type attributes are ignored until a global element declaration is 498 * found for an element. Once a global element declaration has been found, xsi:type 499 * attributes will start being processed for the sub-tree beginning at the element for 500 * which the declaration was found. 501 * 502 * Suppose an element A has two element children, B and C. 503 * 504 * If a global element declaration is found for A, xsi:type attributes on A, B and C, 505 * and all of B and C's descendents, will be processed. 506 * 507 * If no global element declaration is found for A or B, but one is found for C, 508 * then xsi:type attributes will be ignored on A and B (and any descendents of B, 509 * until a global element declaration is found), but xsi:type attributes will be 510 * processed for C and all of C's descendents. 511 * 512 * Once xsi:type attributes stop being ignored for a subtree, they do not start 513 * being ignored again, even if more elements are encountered for which no global 514 * element declaration can be found. 515 */ 516 public static final String IGNORE_XSI_TYPE_FEATURE = "validation/schema/ignore-xsi-type-until-elemdecl"; 517 518 /** Perform checking of ID/IDREFs ("validation/id-idref-checking") */ 519 public static final String ID_IDREF_CHECKING_FEATURE = "validation/id-idref-checking"; 520 521 /** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */ 522 public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking"; 523 524 /** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */ 525 public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking"; 526 527 /** 528 * Internal feature. When set to true the schema validator will only use 529 * schema components from the grammar pool provided. 530 */ 531 public static final String USE_GRAMMAR_POOL_ONLY_FEATURE = "internal/validation/schema/use-grammar-pool-only"; 532 533 /** Internal performance related feature: 534 * false - the parser settings (features/properties) have not changed between 2 parses 535 * true - the parser settings have changed between 2 parses 536 * NOTE: this feature should only be set by the parser configuration. 537 */ 538 public static final String PARSER_SETTINGS = "internal/parser-settings"; 539 540 541 /** Feature to make XML Processor XInclude Aware */ 542 public static final String XINCLUDE_AWARE = "xinclude-aware"; 543 544 /** Ignore xsi:schemaLocation and xsi:noNamespaceSchemaLocation. */ 545 public static final String IGNORE_SCHEMA_LOCATION_HINTS = "validation/schema/ignore-schema-location-hints"; 546 547 /** 548 * When true, the schema processor will change characters events 549 * to ignorableWhitespaces events, when characters are expected to 550 * only contain ignorable whitespaces. 551 */ 552 public static final String CHANGE_IGNORABLE_CHARACTERS_INTO_IGNORABLE_WHITESPACES = 553 "validation/change-ignorable-characters-into-ignorable-whitespaces"; 554 555 // xerces properties 556 557 /** Xerces properties prefix ("http://apache.org/xml/properties/"). */ 558 public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/"; 559 560 /** Current element node property ("dom/current-element-node"). */ 561 public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node"; 562 563 /** Document class name property ("dom/document-class-name"). */ 564 public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name"; 565 566 /** Symbol table property ("internal/symbol-table"). */ 567 public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table"; 568 569 /** Error reporter property ("internal/error-reporter"). */ 570 public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter"; 571 572 /** Error handler property ("internal/error-handler"). */ 573 public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler"; 574 575 /** XInclude handler property ("internal/xinclude-handler"). */ 576 public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler"; 577 578 /** XPointer handler property ("internal/xpointer-handler"). */ 579 public static final String XPOINTER_HANDLER_PROPERTY = "internal/xpointer-handler"; 580 581 /** Entity manager property ("internal/entity-manager"). */ 582 public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager"; 583 /** Input buffer size property ("input-buffer-size"). */ 584 public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size"; 585 586 /** Security manager property ("security-manager"). */ 587 public static final String SECURITY_MANAGER_PROPERTY = "security-manager"; 588 589 /** Locale property ("locale"). */ 590 public static final String LOCALE_PROPERTY = "locale"; 591 592 /** property identifier: security manager. */ 593 public static final String SECURITY_MANAGER = 594 Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY; 595 596 597 public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver"; 598 599 /** Grammar pool property ("internal/grammar-pool"). */ 600 public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool"; 601 602 /** Datatype validator factory ("internal/datatype-validator-factory"). */ 603 public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory"; 604 605 /** Document scanner property ("internal/document-scanner"). */ 606 public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner"; 607 608 /** DTD scanner property ("internal/dtd-scanner"). */ 609 public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner"; 610 611 /** DTD processor property ("internal/dtd-processor"). */ 612 public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor"; 613 614 /** Validator property ("internal/validator"). */ 615 public static final String VALIDATOR_PROPERTY = "internal/validator"; 616 617 /** Validator property ("internal/validator/dtd"). */ 618 public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd"; 619 620 /** Validator property ("internal/validator/schema"). */ 621 public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema"; 622 623 /** No namespace schema location property ("schema/external-schemaLocation"). */ 624 public static final String SCHEMA_LOCATION = "schema/external-schemaLocation"; 625 626 /** Schema location property ("schema/external-noNamespaceSchemaLocation"). */ 627 public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation"; 628 629 /** Namespace binder property ("internal/namespace-binder"). */ 630 public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder"; 631 632 /** Namespace context property ("internal/namespace-context"). */ 633 public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context"; 634 635 /** Validation manager property ("internal/validation-manager"). */ 636 public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager"; 637 638 /** Schema type for the root element in a document ("validation/schema/root-type-definition"). */ 639 public static final String ROOT_TYPE_DEFINITION_PROPERTY = "validation/schema/root-type-definition"; 640 641 /** Schema element declaration for the root element in a document ("validation/schema/root-element-declaration"). */ 642 public static final String ROOT_ELEMENT_DECLARATION_PROPERTY = "validation/schema/root-element-declaration"; 643 644 /** XPointer Schema property ("xpointer-schema"). */ 645 public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema"; 646 647 /** Schema element declaration for the root element in a document ("internal/validation/schema/dv-factory"). */ 648 public static final String SCHEMA_DV_FACTORY_PROPERTY = "internal/validation/schema/dv-factory"; 649 650 651 // general constants 652 653 /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */ 654 public final static String ELEMENT_PSVI = "ELEMENT_PSVI"; 655 656 /** Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */ 657 public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI"; 658 659 /** 660 * Boolean indicating whether an attribute is declared in the DTD is stored 661 * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this 662 * augmentation indicates that the attribute was not declared in the DTD. 663 */ 664 public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED"; 665 666 667 /** 668 * {@link org.w3c.dom.TypeInfo} associated with current element/attribute 669 * is stored in augmentations using this string as the key. 670 * 671 * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} 672 * regarding what object the DOM will return from 673 * {@link org.w3c.dom.Attr#getSchemaTypeInfo()} and 674 * {@link org.w3c.dom.Element#getSchemaTypeInfo()} and 675 */ 676 public final static String TYPEINFO = "org.w3c.dom.TypeInfo"; 677 678 /** 679 * Whether an attribute is an id or not is stored in augmentations 680 * using this string as the key. The value is {@link Boolean#TRUE} 681 * or {@link Boolean#FALSE}. 682 * 683 * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} 684 * about whether it will mark an attribute as ID or not. 685 */ 686 public final static String ID_ATTRIBUTE = "ID_ATTRIBUTE"; 687 688 // XML version constants 689 690 /** 691 * Boolean indicating whether an entity referenced in the document has 692 * not been read is stored in augmentations using the string "ENTITY_SKIPPED". 693 * The absence of this augmentation indicates that the entity had a 694 * declaration and was expanded. 695 */ 696 public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED"; 697 698 /** 699 * Boolean indicating whether a character is a probable white space 700 * character (ch <= 0x20) that was the replacement text of a character 701 * reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS". 702 * The absence of this augmentation indicates that the character is not 703 * probable white space and/or was not included from a character reference. 704 */ 705 public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS"; 706 707 /** Boolean indicating if this entity is the last opened entity. 708 * 709 *@see com.sun.org.apache.xerces.internal.impl.XMLEntityManager#endEntity() 710 *@see com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl#endEntity() 711 *@see com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl#endEntity() 712 */ 713 public final static String LAST_ENTITY = "LAST_ENTITY"; 714 715 // XML version constants 716 public final static short XML_VERSION_ERROR = -1; 717 public final static short XML_VERSION_1_0 = 1; 718 public final static short XML_VERSION_1_1 = 2; 719 720 721 722 // DOM related constants 723 public final static String ANONYMOUS_TYPE_NAMESPACE = 724 "http://apache.org/xml/xmlschema/1.0/anonymousTypes"; 725 726 727 728 // Constant to enable Schema 1.1 support 729 public final static boolean SCHEMA_1_1_SUPPORT = false; 730 public final static short SCHEMA_VERSION_1_0 = 1; 731 public final static short SCHEMA_VERSION_1_0_EXTENDED = 2; 732 733 // private 734 735 /** SAX features. */ 736 private static final String[] fgSAXFeatures = { 737 NAMESPACES_FEATURE, 738 NAMESPACE_PREFIXES_FEATURE, 739 STRING_INTERNING_FEATURE, 740 VALIDATION_FEATURE, 741 EXTERNAL_GENERAL_ENTITIES_FEATURE, 742 EXTERNAL_PARAMETER_ENTITIES_FEATURE, 743 }; 744 745 /** SAX properties. */ 746 private static final String[] fgSAXProperties = { 747 DECLARATION_HANDLER_PROPERTY, 748 LEXICAL_HANDLER_PROPERTY, 749 DOM_NODE_PROPERTY, 750 XML_STRING_PROPERTY, 751 }; 752 753 /** Xerces features. */ 754 private static final String[] fgXercesFeatures = { 755 756 SCHEMA_VALIDATION_FEATURE, 757 SCHEMA_FULL_CHECKING, 758 DYNAMIC_VALIDATION_FEATURE, 759 WARN_ON_DUPLICATE_ATTDEF_FEATURE, 760 WARN_ON_UNDECLARED_ELEMDEF_FEATURE, 761 ALLOW_JAVA_ENCODINGS_FEATURE, 762 CONTINUE_AFTER_FATAL_ERROR_FEATURE, 763 LOAD_DTD_GRAMMAR_FEATURE, 764 LOAD_EXTERNAL_DTD_FEATURE, 765 //DEFER_NODE_EXPANSION_FEATURE, 766 CREATE_ENTITY_REF_NODES_FEATURE, 767 XINCLUDE_AWARE, 768 INCLUDE_IGNORABLE_WHITESPACE, 769 //GRAMMAR_ACCESS_FEATURE, 770 DEFAULT_ATTRIBUTE_VALUES_FEATURE, 771 VALIDATE_CONTENT_MODELS_FEATURE, 772 VALIDATE_DATATYPES_FEATURE, 773 BALANCE_SYNTAX_TREES, 774 NOTIFY_CHAR_REFS_FEATURE, 775 NOTIFY_BUILTIN_REFS_FEATURE, 776 DISALLOW_DOCTYPE_DECL_FEATURE, 777 STANDARD_URI_CONFORMANT_FEATURE, 778 GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE, 779 VALIDATE_ANNOTATIONS_FEATURE, 780 HONOUR_ALL_SCHEMALOCATIONS_FEATURE, 781 XINCLUDE_FEATURE, 782 XINCLUDE_FIXUP_BASE_URIS_FEATURE, 783 XINCLUDE_FIXUP_LANGUAGE_FEATURE, 784 IGNORE_XSI_TYPE_FEATURE, 785 ID_IDREF_CHECKING_FEATURE, 786 IDC_CHECKING_FEATURE, 787 UNPARSED_ENTITY_CHECKING_FEATURE, 788 NAMESPACE_GROWTH_FEATURE, 789 TOLERATE_DUPLICATES_FEATURE, 790 }; 791 792 /** Xerces properties. */ 793 private static final String[] fgXercesProperties = { 794 CURRENT_ELEMENT_NODE_PROPERTY, 795 DOCUMENT_CLASS_NAME_PROPERTY, 796 SYMBOL_TABLE_PROPERTY, 797 ERROR_HANDLER_PROPERTY, 798 ERROR_REPORTER_PROPERTY, 799 ENTITY_MANAGER_PROPERTY, 800 ENTITY_RESOLVER_PROPERTY, 801 XMLGRAMMAR_POOL_PROPERTY, 802 DATATYPE_VALIDATOR_FACTORY_PROPERTY, 803 DOCUMENT_SCANNER_PROPERTY, 804 DTD_SCANNER_PROPERTY, 805 VALIDATOR_PROPERTY, 806 SCHEMA_LOCATION, 807 SCHEMA_NONS_LOCATION, 808 VALIDATION_MANAGER_PROPERTY, 809 BUFFER_SIZE_PROPERTY, 810 SECURITY_MANAGER_PROPERTY, 811 ROOT_TYPE_DEFINITION_PROPERTY, 812 ROOT_ELEMENT_DECLARATION_PROPERTY, 813 LOCALE_PROPERTY, 814 SCHEMA_DV_FACTORY_PROPERTY, 815 }; 816 817 /** Empty enumeration. */ 818 private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object[] {}); 819 820 // 821 // Constructors 822 // 823 824 /** This class cannot be instantiated. */ 825 private Constants() {} 826 827 // 828 // Public methods 829 // 830 831 // sax 832 833 /** Returns an enumeration of the SAX features. */ 834 public static Enumeration getSAXFeatures() { 835 return fgSAXFeatures.length > 0 836 ? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration; 837 } // getSAXFeatures():Enumeration 838 839 /** Returns an enumeration of the SAX properties. */ 840 public static Enumeration getSAXProperties() { 841 return fgSAXProperties.length > 0 842 ? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration; 843 } // getSAXProperties():Enumeration 844 845 // xerces 846 847 /** Returns an enumeration of the Xerces features. */ 848 public static Enumeration getXercesFeatures() { 849 return fgXercesFeatures.length > 0 850 ? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration; 851 } // getXercesFeatures():Enumeration 852 853 /** Returns an enumeration of the Xerces properties. */ 854 public static Enumeration getXercesProperties() { 855 return fgXercesProperties.length > 0 856 ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; 857 } // getXercesProperties():Enumeration 858 859 /* 860 * Check the major version of the current JDK against that specified 861 * in the parameter 862 * 863 * In JDK9 the java version string was changed to comply with JEP-223 864 * so this method was modified to handle that new format as well 865 * 866 * @param compareTo a JDK major version to be compared to 867 * @return true if the current major version is the same or above 868 * that represented by the parameter 869 */ 870 public static boolean isJavaVersionAtLeast(int compareTo) { 871 String javaVersion = SecuritySupport.getSystemProperty("java.version"); 872 javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ? 873 javaVersion.split("-|\\.")[0] : 874 javaVersion.split("\\.", 3)[1]; 875 return Integer.parseInt(javaVersion) >= compareTo; 876 } 877 878 // 879 // Classes 880 // 881 882 /** 883 * An array enumeration. 884 * 885 * @author Andy Clark, IBM 886 */ 887 static class ArrayEnumeration 888 implements Enumeration { 889 890 // 891 // Data 892 // 893 894 /** Array. */ 895 private Object[] array; 896 897 /** Index. */ 898 private int index; 899 900 // 901 // Constructors 902 // 903 904 /** Constructs an array enumeration. */ 905 public ArrayEnumeration(Object[] array) { 906 this.array = array; 907 } // <init>(Object[]) 908 909 // 910 // Enumeration methods 911 // 912 913 /** 914 * Tests if this enumeration contains more elements. 915 * 916 * @return <code>true</code> if this enumeration contains more elements; 917 * <code>false</code> otherwise. 918 * @since JDK1.0 919 */ 920 public boolean hasMoreElements() { 921 return index < array.length; 922 } // hasMoreElement():boolean 923 924 /** 925 * Returns the next element of this enumeration. 926 * 927 * @return the next element of this enumeration. 928 * @exception NoSuchElementException if no more elements exist. 929 * @since JDK1.0 930 */ 931 public Object nextElement() { 932 if (index < array.length) { 933 return array[index++]; 934 } 935 throw new NoSuchElementException(); 936 } // nextElement():Object 937 938 } // class ArrayEnumeration 939 940 // 941 // MAIN 942 // 943 944 /** Prints all of the constants to standard output. */ 945 public static void main(String[] argv) { 946 947 print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures); 948 print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties); 949 print("Xerces features:", XERCES_FEATURE_PREFIX, fgXercesFeatures); 950 print("Xerces properties:", XERCES_PROPERTY_PREFIX, fgXercesProperties); 951 952 } // main(String[]) 953 954 /** Prints a list of features/properties. */ 955 private static void print(String header, String prefix, Object[] array) { 956 System.out.print(header); 957 if (array.length > 0) { 958 System.out.println(); 959 for (int i = 0; i < array.length; i++) { 960 System.out.print(" "); 961 System.out.print(prefix); 962 System.out.println(array[i]); 963 } 964 } 965 else { 966 System.out.println(" none."); 967 } 968 } // print(String,String,Object[]) 969 970 } // class Constants