rev 1063 : 8172974: [JAXP] XALAN: Wrong result when transforming namespace unaware StAX Input

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