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