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 // Implementation limits: corresponding System Properties of the above 208 // API properties 209 // 210 /** 211 * JDK entity expansion limit; Note that the existing system property 212 * "entityExpansionLimit" with no prefix is still observed 213 */ 214 public static final String JDK_ENTITY_EXPANSION_LIMIT = 215 ORACLE_JAXP_PROPERTY_PREFIX + "entityExpansionLimit"; 216 217 /** 218 * JDK element attribute limit; Note that the existing system property 219 * "elementAttributeLimit" with no prefix is still observed 220 */ 221 public static final String JDK_ELEMENT_ATTRIBUTE_LIMIT = 222 ORACLE_JAXP_PROPERTY_PREFIX + "elementAttributeLimit"; 223 224 /** 225 * JDK maxOccur limit; Note that the existing system property 226 * "maxOccurLimit" with no prefix is still observed 227 */ 228 public static final String JDK_MAX_OCCUR_LIMIT = 229 ORACLE_JAXP_PROPERTY_PREFIX + "maxOccurLimit"; 230 231 /** 232 * JDK total entity size limit 233 */ 234 public static final String JDK_TOTAL_ENTITY_SIZE_LIMIT = 235 ORACLE_JAXP_PROPERTY_PREFIX + "totalEntitySizeLimit"; 236 237 /** 238 * JDK maximum general entity size limit 239 */ 240 public static final String JDK_GENERAL_ENTITY_SIZE_LIMIT = 241 ORACLE_JAXP_PROPERTY_PREFIX + "maxGeneralEntitySizeLimit"; 242 /** 243 * JDK maximum parameter entity size limit 244 */ 245 public static final String JDK_PARAMETER_ENTITY_SIZE_LIMIT = 246 ORACLE_JAXP_PROPERTY_PREFIX + "maxParameterEntitySizeLimit"; 247 /** 248 * JDK maximum XML name limit 249 */ 250 public static final String JDK_XML_NAME_LIMIT = 251 ORACLE_JAXP_PROPERTY_PREFIX + "maxXMLNameLimit"; 252 253 /** 254 * JDK maxElementDepth limit 255 */ 256 public static final String JDK_MAX_ELEMENT_DEPTH = 257 ORACLE_JAXP_PROPERTY_PREFIX + "maxElementDepth"; 258 259 /** 260 * JDK property to allow printing out information from the limit analyzer 261 */ 262 public static final String JDK_ENTITY_COUNT_INFO = 263 ORACLE_JAXP_PROPERTY_PREFIX + "getEntityCountInfo"; 264 265 // 266 // Implementation limits: API properties 267 // 268 /** 269 * JDK entity expansion limit; Note that the existing system property 270 * "entityExpansionLimit" with no prefix is still observed 271 */ 272 public static final String SP_ENTITY_EXPANSION_LIMIT = "jdk.xml.entityExpansionLimit"; 273 274 /** 275 * JDK element attribute limit; Note that the existing system property 276 * "elementAttributeLimit" with no prefix is still observed 277 */ 278 public static final String SP_ELEMENT_ATTRIBUTE_LIMIT = "jdk.xml.elementAttributeLimit"; 279 280 /** 281 * JDK maxOccur limit; Note that the existing system property 282 * "maxOccurLimit" with no prefix is still observed 283 */ 284 public static final String SP_MAX_OCCUR_LIMIT = "jdk.xml.maxOccurLimit"; 285 286 /** 287 * JDK total entity size limit 288 */ 289 public static final String SP_TOTAL_ENTITY_SIZE_LIMIT = "jdk.xml.totalEntitySizeLimit"; 290 291 /** 292 * JDK maximum general entity size limit 293 */ 294 public static final String SP_GENERAL_ENTITY_SIZE_LIMIT = "jdk.xml.maxGeneralEntitySizeLimit"; 295 /** 296 * JDK maximum parameter entity size limit 297 */ 298 public static final String SP_PARAMETER_ENTITY_SIZE_LIMIT = "jdk.xml.maxParameterEntitySizeLimit"; 299 /** 300 * JDK maximum XML name limit 301 */ 302 public static final String SP_XML_NAME_LIMIT = "jdk.xml.maxXMLNameLimit"; 303 304 /** 305 * JDK maxElementDepth limit 306 */ 307 public static final String SP_MAX_ELEMENT_DEPTH = "jdk.xml.maxElementDepth"; 308 309 //legacy System Properties 310 public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit"; 311 public static final String ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ; 312 public final static String MAX_OCCUR_LIMIT = "maxOccurLimit"; 313 314 /** 315 * A string "yes" that can be used for properties such as getEntityCountInfo 316 */ 317 public static final String JDK_YES = "yes"; 318 319 // 320 // DOM features 321 // 322 323 /** Comments feature ("include-comments"). */ 324 public static final String INCLUDE_COMMENTS_FEATURE = "include-comments"; 325 326 /** Create cdata nodes feature ("create-cdata-nodes"). */ 327 public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes"; 328 329 /** Feature id: load as infoset. */ 330 public static final String LOAD_AS_INFOSET = "load-as-infoset"; 331 332 333 // 334 // Constants: DOM Level 3 feature ids 335 // 336 337 public static final String DOM_CANONICAL_FORM = "canonical-form"; 338 public static final String DOM_CDATA_SECTIONS ="cdata-sections"; 339 340 public static final String DOM_COMMENTS = "comments"; 341 342 // REVISIT: this feature seems to have no effect for Xerces 343 344 public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = 345 "charset-overrides-xml-encoding"; 346 347 public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization"; 348 349 public static final String DOM_ENTITIES = "entities"; 350 public static final String DOM_INFOSET = "infoset"; 351 public static final String DOM_NAMESPACES = "namespaces"; 352 public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations"; 353 public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = 354 "supported-media-types-only"; 355 356 public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema"; 357 public static final String DOM_VALIDATE = "validate"; 358 public static final String DOM_ELEMENT_CONTENT_WHITESPACE = 359 "element-content-whitespace"; 360 361 // DOM Level 3 features defined in Core: 362 public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content"; 363 public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters"; 364 public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization"; 365 public static final String DOM_WELLFORMED = "well-formed"; 366 public static final String DOM_SPLIT_CDATA = "split-cdata-sections"; 367 368 // Load and Save 369 public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print"; 370 public static final String DOM_XMLDECL = "xml-declaration"; 371 public static final String DOM_UNKNOWNCHARS = "unknown-characters"; 372 public static final String DOM_CERTIFIED = "certified"; 373 public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype"; 374 public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations"; 375 376 // DOM Properties 377 public static final String DOM_RESOURCE_RESOLVER = "resource-resolver"; 378 public static final String DOM_ERROR_HANDLER = "error-handler"; 379 public static final String DOM_SCHEMA_TYPE = "schema-type"; 380 public static final String DOM_SCHEMA_LOCATION = "schema-location"; 381 public static final String DOM_ANCESTOR_CHECCK = "ancestor-check"; 382 // XSModel 383 public static final String DOM_PSVI = "psvi"; 384 385 386 // xerces features 387 388 /** Xerces features prefix ("http://apache.org/xml/features/"). */ 389 public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/"; 390 391 /** Schema validation feature ("validation/schema"). */ 392 public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema"; 393 394 /** Expose schema normalized values */ 395 public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value"; 396 397 /** Send schema default value via characters() */ 398 public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default"; 399 400 /** Schema full constraint checking ("validation/schema-full-checking"). */ 401 public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking"; 402 403 /** Augment Post-Schema-Validation-Infoset */ 404 public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi"; 405 406 /** Dynamic validation feature ("validation/dynamic"). */ 407 public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic"; 408 409 /** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */ 410 public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef"; 411 412 /** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */ 413 public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef"; 414 415 /** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */ 416 public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef"; 417 418 /** Allow Java encoding names feature ("allow-java-encodings"). */ 419 public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings"; 420 421 /** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */ 422 public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl"; 423 424 /** Continue after fatal error feature ("continue-after-fatal-error"). */ 425 public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error"; 426 427 /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */ 428 public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar"; 429 430 /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */ 431 public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd"; 432 433 /** Defer node expansion feature ("dom/defer-node-expansion"). */ 434 public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion"; 435 436 /** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */ 437 public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes"; 438 439 /** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */ 440 public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace"; 441 442 /** Default attribute values feature ("validation/default-attribute-values"). */ 443 public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values"; 444 445 /** Validate content models feature ("validation/validate-content-models"). */ 446 public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models"; 447 448 /** Validate datatypes feature ("validation/validate-datatypes"). */ 449 public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes"; 450 451 /** Balance syntax trees feature ("validation/balance-syntax-trees"). */ 452 public static final String BALANCE_SYNTAX_TREES = "validation/balance-syntax-trees"; 453 454 /** Notify character references feature (scanner/notify-char-refs"). */ 455 public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs"; 456 457 /** Notify built-in (&amp;, etc.) references feature (scanner/notify-builtin-refs"). */ 458 public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs"; 459 460 /** Standard URI conformant feature ("standard-uri-conformant"). */ 461 public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant"; 462 463 /** Generate synthetic annotations feature ("generate-synthetic-annotations"). */ 464 public static final String GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE = "generate-synthetic-annotations"; 465 466 /** Validate annotations feature ("validate-annotations"). */ 467 public static final String VALIDATE_ANNOTATIONS_FEATURE = "validate-annotations"; 468 469 470 /** Honour all schemaLocations feature ("honour-all-schemaLocations"). */ 471 public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations"; 472 473 /** Namespace growth feature ("namespace-growth"). */ 474 public static final String NAMESPACE_GROWTH_FEATURE = "namespace-growth"; 475 476 /** Tolerate duplicates feature ("internal/tolerate-duplicates"). */ 477 public static final String TOLERATE_DUPLICATES_FEATURE = "internal/tolerate-duplicates"; 478 479 /** XInclude processing feature ("xinclude"). */ 480 public static final String XINCLUDE_FEATURE = "xinclude"; 481 482 /** XInclude fixup base URIs feature ("xinclude/fixup-base-uris"). */ 483 public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris"; 484 485 /** XInclude fixup language feature ("xinclude/fixup-language"). */ 486 public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language"; 487 488 /** 489 * Feature to ignore xsi:type attributes on elements during validation, 490 * until a global element declaration is found. ("validation/schema/ignore-xsi-type-until-elemdecl") 491 * If this feature is on when validating a document, then beginning at the validation root 492 * element, xsi:type attributes are ignored until a global element declaration is 493 * found for an element. Once a global element declaration has been found, xsi:type 494 * attributes will start being processed for the sub-tree beginning at the element for 495 * which the declaration was found. 496 * 497 * Suppose an element A has two element children, B and C. 498 * 499 * If a global element declaration is found for A, xsi:type attributes on A, B and C, 500 * and all of B and C's descendents, will be processed. 501 * 502 * If no global element declaration is found for A or B, but one is found for C, 503 * then xsi:type attributes will be ignored on A and B (and any descendents of B, 504 * until a global element declaration is found), but xsi:type attributes will be 505 * processed for C and all of C's descendents. 506 * 507 * Once xsi:type attributes stop being ignored for a subtree, they do not start 508 * being ignored again, even if more elements are encountered for which no global 509 * element declaration can be found. 510 */ 511 public static final String IGNORE_XSI_TYPE_FEATURE = "validation/schema/ignore-xsi-type-until-elemdecl"; 512 513 /** Perform checking of ID/IDREFs ("validation/id-idref-checking") */ 514 public static final String ID_IDREF_CHECKING_FEATURE = "validation/id-idref-checking"; 515 516 /** Feature to ignore errors caused by identity constraints ("validation/identity-constraint-checking") */ 517 public static final String IDC_CHECKING_FEATURE = "validation/identity-constraint-checking"; 518 519 /** Feature to ignore errors caused by unparsed entities ("validation/unparsed-entity-checking") */ 520 public static final String UNPARSED_ENTITY_CHECKING_FEATURE = "validation/unparsed-entity-checking"; 521 522 /** 523 * Internal feature. When set to true the schema validator will only use 524 * schema components from the grammar pool provided. 525 */ 526 public static final String USE_GRAMMAR_POOL_ONLY_FEATURE = "internal/validation/schema/use-grammar-pool-only"; 527 528 /** Internal performance related feature: 529 * false - the parser settings (features/properties) have not changed between 2 parses 530 * true - the parser settings have changed between 2 parses 531 * NOTE: this feature should only be set by the parser configuration. 532 */ 533 public static final String PARSER_SETTINGS = "internal/parser-settings"; 534 535 536 /** Feature to make XML Processor XInclude Aware */ 537 public static final String XINCLUDE_AWARE = "xinclude-aware"; 538 539 /** Ignore xsi:schemaLocation and xsi:noNamespaceSchemaLocation. */ 540 public static final String IGNORE_SCHEMA_LOCATION_HINTS = "validation/schema/ignore-schema-location-hints"; 541 542 /** 543 * When true, the schema processor will change characters events 544 * to ignorableWhitespaces events, when characters are expected to 545 * only contain ignorable whitespaces. 546 */ 547 public static final String CHANGE_IGNORABLE_CHARACTERS_INTO_IGNORABLE_WHITESPACES = 548 "validation/change-ignorable-characters-into-ignorable-whitespaces"; 549 550 // xerces properties 551 552 /** Xerces properties prefix ("http://apache.org/xml/properties/"). */ 553 public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/"; 554 555 /** Current element node property ("dom/current-element-node"). */ 556 public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node"; 557 558 /** Document class name property ("dom/document-class-name"). */ 559 public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name"; 560 561 /** Symbol table property ("internal/symbol-table"). */ 562 public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table"; 563 564 /** Error reporter property ("internal/error-reporter"). */ 565 public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter"; 566 567 /** Error handler property ("internal/error-handler"). */ 568 public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler"; 569 570 /** XInclude handler property ("internal/xinclude-handler"). */ 571 public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler"; 572 573 /** XPointer handler property ("internal/xpointer-handler"). */ 574 public static final String XPOINTER_HANDLER_PROPERTY = "internal/xpointer-handler"; 575 576 /** Entity manager property ("internal/entity-manager"). */ 577 public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager"; 578 /** Input buffer size property ("input-buffer-size"). */ 579 public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size"; 580 581 /** Security manager property ("security-manager"). */ 582 public static final String SECURITY_MANAGER_PROPERTY = "security-manager"; 583 584 /** Locale property ("locale"). */ 585 public static final String LOCALE_PROPERTY = "locale"; 586 587 /** property identifier: security manager. */ 588 public static final String SECURITY_MANAGER = 589 Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY; 590 591 592 public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver"; 593 594 /** Grammar pool property ("internal/grammar-pool"). */ 595 public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool"; 596 597 /** Datatype validator factory ("internal/datatype-validator-factory"). */ 598 public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory"; 599 600 /** Document scanner property ("internal/document-scanner"). */ 601 public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner"; 602 603 /** DTD scanner property ("internal/dtd-scanner"). */ 604 public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner"; 605 606 /** DTD processor property ("internal/dtd-processor"). */ 607 public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor"; 608 609 /** Validator property ("internal/validator"). */ 610 public static final String VALIDATOR_PROPERTY = "internal/validator"; 611 612 /** Validator property ("internal/validator/dtd"). */ 613 public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd"; 614 615 /** Validator property ("internal/validator/schema"). */ 616 public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema"; 617 618 /** No namespace schema location property ("schema/external-schemaLocation"). */ 619 public static final String SCHEMA_LOCATION = "schema/external-schemaLocation"; 620 621 /** Schema location property ("schema/external-noNamespaceSchemaLocation"). */ 622 public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation"; 623 624 /** Namespace binder property ("internal/namespace-binder"). */ 625 public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder"; 626 627 /** Namespace context property ("internal/namespace-context"). */ 628 public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context"; 629 630 /** Validation manager property ("internal/validation-manager"). */ 631 public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager"; 632 633 /** Schema type for the root element in a document ("validation/schema/root-type-definition"). */ 634 public static final String ROOT_TYPE_DEFINITION_PROPERTY = "validation/schema/root-type-definition"; 635 636 /** Schema element declaration for the root element in a document ("validation/schema/root-element-declaration"). */ 637 public static final String ROOT_ELEMENT_DECLARATION_PROPERTY = "validation/schema/root-element-declaration"; 638 639 /** XPointer Schema property ("xpointer-schema"). */ 640 public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema"; 641 642 /** Schema element declaration for the root element in a document ("internal/validation/schema/dv-factory"). */ 643 public static final String SCHEMA_DV_FACTORY_PROPERTY = "internal/validation/schema/dv-factory"; 644 645 646 // general constants 647 648 /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */ 649 public final static String ELEMENT_PSVI = "ELEMENT_PSVI"; 650 651 /** Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */ 652 public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI"; 653 654 /** 655 * Boolean indicating whether an attribute is declared in the DTD is stored 656 * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this 657 * augmentation indicates that the attribute was not declared in the DTD. 658 */ 659 public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED"; 660 661 662 /** 663 * {@link org.w3c.dom.TypeInfo} associated with current element/attribute 664 * is stored in augmentations using this string as the key. 665 * 666 * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} 667 * regarding what object the DOM will return from 668 * {@link org.w3c.dom.Attr#getSchemaTypeInfo()} and 669 * {@link org.w3c.dom.Element#getSchemaTypeInfo()} and 670 */ 671 public final static String TYPEINFO = "org.w3c.dom.TypeInfo"; 672 673 /** 674 * Whether an attribute is an id or not is stored in augmentations 675 * using this string as the key. The value is {@link Boolean#TRUE} 676 * or {@link Boolean#FALSE}. 677 * 678 * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser} 679 * about whether it will mark an attribute as ID or not. 680 */ 681 public final static String ID_ATTRIBUTE = "ID_ATTRIBUTE"; 682 683 // XML version constants 684 685 /** 686 * Boolean indicating whether an entity referenced in the document has 687 * not been read is stored in augmentations using the string "ENTITY_SKIPPED". 688 * The absence of this augmentation indicates that the entity had a 689 * declaration and was expanded. 690 */ 691 public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED"; 692 693 /** 694 * Boolean indicating whether a character is a probable white space 695 * character (ch <= 0x20) that was the replacement text of a character 696 * reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS". 697 * The absence of this augmentation indicates that the character is not 698 * probable white space and/or was not included from a character reference. 699 */ 700 public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS"; 701 702 /** Boolean indicating if this entity is the last opened entity. 703 * 704 *@see com.sun.org.apache.xerces.internal.impl.XMLEntityManager#endEntity() 705 *@see com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl#endEntity() 706 *@see com.sun.org.apache.xerces.internal.impl.XMLDTDScannerImpl#endEntity() 707 */ 708 public final static String LAST_ENTITY = "LAST_ENTITY"; 709 710 // XML version constants 711 public final static short XML_VERSION_ERROR = -1; 712 public final static short XML_VERSION_1_0 = 1; 713 public final static short XML_VERSION_1_1 = 2; 714 715 716 717 // DOM related constants 718 public final static String ANONYMOUS_TYPE_NAMESPACE = 719 "http://apache.org/xml/xmlschema/1.0/anonymousTypes"; 720 721 722 723 // Constant to enable Schema 1.1 support 724 public final static boolean SCHEMA_1_1_SUPPORT = false; 725 public final static short SCHEMA_VERSION_1_0 = 1; 726 public final static short SCHEMA_VERSION_1_0_EXTENDED = 2; 727 728 // private 729 730 /** SAX features. */ 731 private static final String[] fgSAXFeatures = { 732 NAMESPACES_FEATURE, 733 NAMESPACE_PREFIXES_FEATURE, 734 STRING_INTERNING_FEATURE, 735 VALIDATION_FEATURE, 736 EXTERNAL_GENERAL_ENTITIES_FEATURE, 737 EXTERNAL_PARAMETER_ENTITIES_FEATURE, 738 }; 739 740 /** SAX properties. */ 741 private static final String[] fgSAXProperties = { 742 DECLARATION_HANDLER_PROPERTY, 743 LEXICAL_HANDLER_PROPERTY, 744 DOM_NODE_PROPERTY, 745 XML_STRING_PROPERTY, 746 }; 747 748 /** Xerces features. */ 749 private static final String[] fgXercesFeatures = { 750 751 SCHEMA_VALIDATION_FEATURE, 752 SCHEMA_FULL_CHECKING, 753 DYNAMIC_VALIDATION_FEATURE, 754 WARN_ON_DUPLICATE_ATTDEF_FEATURE, 755 WARN_ON_UNDECLARED_ELEMDEF_FEATURE, 756 ALLOW_JAVA_ENCODINGS_FEATURE, 757 CONTINUE_AFTER_FATAL_ERROR_FEATURE, 758 LOAD_DTD_GRAMMAR_FEATURE, 759 LOAD_EXTERNAL_DTD_FEATURE, 760 //DEFER_NODE_EXPANSION_FEATURE, 761 CREATE_ENTITY_REF_NODES_FEATURE, 762 XINCLUDE_AWARE, 763 INCLUDE_IGNORABLE_WHITESPACE, 764 //GRAMMAR_ACCESS_FEATURE, 765 DEFAULT_ATTRIBUTE_VALUES_FEATURE, 766 VALIDATE_CONTENT_MODELS_FEATURE, 767 VALIDATE_DATATYPES_FEATURE, 768 BALANCE_SYNTAX_TREES, 769 NOTIFY_CHAR_REFS_FEATURE, 770 NOTIFY_BUILTIN_REFS_FEATURE, 771 DISALLOW_DOCTYPE_DECL_FEATURE, 772 STANDARD_URI_CONFORMANT_FEATURE, 773 GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE, 774 VALIDATE_ANNOTATIONS_FEATURE, 775 HONOUR_ALL_SCHEMALOCATIONS_FEATURE, 776 XINCLUDE_FEATURE, 777 XINCLUDE_FIXUP_BASE_URIS_FEATURE, 778 XINCLUDE_FIXUP_LANGUAGE_FEATURE, 779 IGNORE_XSI_TYPE_FEATURE, 780 ID_IDREF_CHECKING_FEATURE, 781 IDC_CHECKING_FEATURE, 782 UNPARSED_ENTITY_CHECKING_FEATURE, 783 NAMESPACE_GROWTH_FEATURE, 784 TOLERATE_DUPLICATES_FEATURE, 785 }; 786 787 /** Xerces properties. */ 788 private static final String[] fgXercesProperties = { 789 CURRENT_ELEMENT_NODE_PROPERTY, 790 DOCUMENT_CLASS_NAME_PROPERTY, 791 SYMBOL_TABLE_PROPERTY, 792 ERROR_HANDLER_PROPERTY, 793 ERROR_REPORTER_PROPERTY, 794 ENTITY_MANAGER_PROPERTY, 795 ENTITY_RESOLVER_PROPERTY, 796 XMLGRAMMAR_POOL_PROPERTY, 797 DATATYPE_VALIDATOR_FACTORY_PROPERTY, 798 DOCUMENT_SCANNER_PROPERTY, 799 DTD_SCANNER_PROPERTY, 800 VALIDATOR_PROPERTY, 801 SCHEMA_LOCATION, 802 SCHEMA_NONS_LOCATION, 803 VALIDATION_MANAGER_PROPERTY, 804 BUFFER_SIZE_PROPERTY, 805 SECURITY_MANAGER_PROPERTY, 806 ROOT_TYPE_DEFINITION_PROPERTY, 807 ROOT_ELEMENT_DECLARATION_PROPERTY, 808 LOCALE_PROPERTY, 809 SCHEMA_DV_FACTORY_PROPERTY, 810 }; 811 812 /** Empty enumeration. */ 813 private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object[] {}); 814 815 // 816 // Constructors 817 // 818 819 /** This class cannot be instantiated. */ 820 private Constants() {} 821 822 // 823 // Public methods 824 // 825 826 // sax 827 828 /** Returns an enumeration of the SAX features. */ 829 public static Enumeration getSAXFeatures() { 830 return fgSAXFeatures.length > 0 831 ? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration; 832 } // getSAXFeatures():Enumeration 833 834 /** Returns an enumeration of the SAX properties. */ 835 public static Enumeration getSAXProperties() { 836 return fgSAXProperties.length > 0 837 ? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration; 838 } // getSAXProperties():Enumeration 839 840 // xerces 841 842 /** Returns an enumeration of the Xerces features. */ 843 public static Enumeration getXercesFeatures() { 844 return fgXercesFeatures.length > 0 845 ? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration; 846 } // getXercesFeatures():Enumeration 847 848 /** Returns an enumeration of the Xerces properties. */ 849 public static Enumeration getXercesProperties() { 850 return fgXercesProperties.length > 0 851 ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; 852 } // getXercesProperties():Enumeration 853 854 // 855 // Classes 856 // 857 858 /** 859 * An array enumeration. 860 * 861 * @author Andy Clark, IBM 862 */ 863 static class ArrayEnumeration 864 implements Enumeration { 865 866 // 867 // Data 868 // 869 870 /** Array. */ 871 private Object[] array; 872 873 /** Index. */ 874 private int index; 875 876 // 877 // Constructors 878 // 879 880 /** Constructs an array enumeration. */ 881 public ArrayEnumeration(Object[] array) { 882 this.array = array; 883 } // <init>(Object[]) 884 885 // 886 // Enumeration methods 887 // 888 889 /** 890 * Tests if this enumeration contains more elements. 891 * 892 * @return <code>true</code> if this enumeration contains more elements; 893 * <code>false</code> otherwise. 894 * @since JDK1.0 895 */ 896 public boolean hasMoreElements() { 897 return index < array.length; 898 } // hasMoreElement():boolean 899 900 /** 901 * Returns the next element of this enumeration. 902 * 903 * @return the next element of this enumeration. 904 * @exception NoSuchElementException if no more elements exist. 905 * @since JDK1.0 906 */ 907 public Object nextElement() { 908 if (index < array.length) { 909 return array[index++]; 910 } 911 throw new NoSuchElementException(); 912 } // nextElement():Object 913 914 } // class ArrayEnumeration 915 916 // 917 // MAIN 918 // 919 920 /** Prints all of the constants to standard output. */ 921 public static void main(String[] argv) { 922 923 print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures); 924 print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties); 925 print("Xerces features:", XERCES_FEATURE_PREFIX, fgXercesFeatures); 926 print("Xerces properties:", XERCES_PROPERTY_PREFIX, fgXercesProperties); 927 928 } // main(String[]) 929 930 /** Prints a list of features/properties. */ 931 private static void print(String header, String prefix, Object[] array) { 932 System.out.print(header); 933 if (array.length > 0) { 934 System.out.println(); 935 for (int i = 0; i < array.length; i++) { 936 System.out.print(" "); 937 System.out.print(prefix); 938 System.out.println(array[i]); 939 } 940 } 941 else { 942 System.out.println(" none."); 943 } 944 } // print(String,String,Object[]) 945 946 } // class Constants