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