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