1 16 17 package org.apache.xerces.impl; 18 19 import java.util.Enumeration ; 20 import java.util.NoSuchElementException ; 21 22 31 public final class Constants { 32 33 public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern(); 38 public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern(); 39 40 42 43 public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/"; 44 45 46 public static final String NAMESPACES_FEATURE = "namespaces"; 47 48 49 public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes"; 50 51 52 public static final String STRING_INTERNING_FEATURE = "string-interning"; 53 54 55 public static final String VALIDATION_FEATURE = "validation"; 56 57 58 public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities"; 59 60 61 public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities"; 62 63 64 public static final String LEXICAL_HANDLER_PARAMETER_ENTITIES_FEATURE = "lexical-handler/parameter-entities"; 65 66 67 public static final String IS_STANDALONE_FEATURE = "is-standalone"; 68 69 70 public static final String RESOLVE_DTD_URIS_FEATURE = "resolve-dtd-uris"; 71 72 73 public static final String USE_ATTRIBUTES2_FEATURE = "use-attributes2"; 74 75 76 public static final String USE_LOCATOR2_FEATURE = "use-locator2"; 77 78 79 public static final String USE_ENTITY_RESOLVER2_FEATURE = "use-entity-resolver2"; 80 81 82 public static final String UNICODE_NORMALIZATION_CHECKING_FEATURE = "unicode-normalization-checking"; 83 84 85 public static final String XMLNS_URIS_FEATURE = "xmlns-uris"; 86 87 88 public static final String XML_11_FEATURE = "xml-1.1"; 89 90 91 public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD"; 92 93 95 96 public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/"; 97 98 99 public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler"; 100 101 102 public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler"; 103 104 105 public static final String DOM_NODE_PROPERTY = "dom-node"; 106 107 108 public static final String XML_STRING_PROPERTY = "xml-string"; 109 110 111 public static final String DOCUMENT_XML_VERSION_PROPERTY = "document-xml-version"; 112 113 114 118 119 public static final String JAXP_PROPERTY_PREFIX = 120 "http://java.sun.com/xml/jaxp/properties/"; 121 122 123 public static final String SCHEMA_SOURCE = "schemaSource"; 124 125 126 public static final String SCHEMA_LANGUAGE = "schemaLanguage"; 127 128 129 133 134 public static final String INCLUDE_COMMENTS_FEATURE = "include-comments"; 135 136 137 public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes"; 138 139 140 public static final String LOAD_AS_INFOSET = "load-as-infoset"; 141 142 143 147 public static final String DOM_CANONICAL_FORM = "canonical-form"; 148 public static final String DOM_CDATA_SECTIONS ="cdata-sections"; 149 public static final String DOM_COMMENTS = "comments"; 150 151 public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING = 153 "charset-overrides-xml-encoding"; 154 155 public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization"; 156 public static final String DOM_ENTITIES = "entities"; 157 public static final String DOM_INFOSET = "infoset"; 158 public static final String DOM_NAMESPACES = "namespaces"; 159 public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations"; 160 public static final String DOM_SUPPORTED_MEDIATYPES_ONLY = 161 "supported-media-types-only"; 162 163 public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema"; 164 public static final String DOM_VALIDATE = "validate"; 165 public static final String DOM_ELEMENT_CONTENT_WHITESPACE = 166 "element-content-whitespace"; 167 168 public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content"; 170 public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters"; 171 public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization"; 172 public static final String DOM_WELLFORMED = "well-formed"; 173 public static final String DOM_SPLIT_CDATA = "split-cdata-sections"; 174 175 public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print"; 177 public static final String DOM_XMLDECL = "xml-declaration"; 178 public static final String DOM_UNKNOWNCHARS = "unknown-characters"; 179 public static final String DOM_CERTIFIED = "certified"; 180 public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype"; 181 public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations"; 182 183 public static final String DOM_RESOURCE_RESOLVER = "resource-resolver"; 185 public static final String DOM_ERROR_HANDLER = "error-handler"; 186 public static final String DOM_SCHEMA_TYPE = "schema-type"; 187 public static final String DOM_SCHEMA_LOCATION = "schema-location"; 188 189 public static final String DOM_PSVI = "psvi"; 191 192 193 195 196 public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/"; 197 198 199 public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema"; 200 201 202 public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value"; 203 204 205 public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default"; 206 207 208 public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking"; 209 210 211 public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi"; 212 213 214 public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic"; 215 216 217 public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef"; 218 219 220 public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef"; 221 222 223 public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef"; 224 225 226 public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings"; 227 228 229 public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl"; 230 231 232 public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error"; 233 234 235 public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar"; 236 237 238 public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd"; 239 240 241 public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion"; 242 243 244 public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes"; 245 246 247 public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace"; 248 249 250 public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values"; 251 252 253 public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models"; 254 255 256 public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes"; 257 258 259 public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs"; 260 261 262 public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs"; 263 264 265 public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant"; 266 267 268 public static final String GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE = "generate-synthetic-annotations"; 269 270 271 public static final String VALIDATE_ANNOTATIONS_FEATURE = "validate-annotations"; 272 273 274 public static final String HONOUR_ALL_SCHEMALOCATIONS_FEATURE = "honour-all-schemaLocations"; 275 276 277 public static final String XINCLUDE_FEATURE = "xinclude"; 278 279 280 public static final String XINCLUDE_FIXUP_BASE_URIS_FEATURE = "xinclude/fixup-base-uris"; 281 282 283 public static final String XINCLUDE_FIXUP_LANGUAGE_FEATURE = "xinclude/fixup-language"; 284 285 289 public static final String USE_GRAMMAR_POOL_ONLY_FEATURE = "internal/validation/schema/use-grammar-pool-only"; 290 291 296 public static final String PARSER_SETTINGS = "internal/parser-settings"; 297 298 300 301 public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/"; 302 303 304 public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node"; 305 306 307 public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name"; 308 309 310 public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table"; 311 312 313 public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter"; 314 315 316 public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler"; 317 318 319 public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler"; 320 321 322 public static final String XPOINTER_HANDLER_PROPERTY = "internal/xpointer-handler"; 323 324 325 public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager"; 326 327 328 329 public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size"; 330 331 332 public static final String SECURITY_MANAGER_PROPERTY = "security-manager"; 333 334 335 public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver"; 336 337 338 public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool"; 339 340 341 public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory"; 342 343 344 public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner"; 345 346 347 public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner"; 348 349 350 public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor"; 351 352 353 public static final String VALIDATOR_PROPERTY = "internal/validator"; 354 355 356 public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd"; 357 358 359 public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema"; 360 361 362 public static final String SCHEMA_LOCATION = "schema/external-schemaLocation"; 363 364 365 public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation"; 366 367 368 public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder"; 369 370 371 public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context"; 372 373 374 public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager"; 375 376 378 379 public final static String ELEMENT_PSVI = "ELEMENT_PSVI"; 380 381 382 public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI"; 383 384 389 public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED"; 390 391 397 public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED"; 398 399 406 public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS"; 407 408 public final static short XML_VERSION_1_0 = 1; 410 public final static short XML_VERSION_1_1 = 2; 411 412 public final static boolean SCHEMA_1_1_SUPPORT = false; 414 415 417 418 private static final String [] fgSAXFeatures = { 419 NAMESPACES_FEATURE, 420 NAMESPACE_PREFIXES_FEATURE, 421 STRING_INTERNING_FEATURE, 422 VALIDATION_FEATURE, 423 EXTERNAL_GENERAL_ENTITIES_FEATURE, 424 EXTERNAL_PARAMETER_ENTITIES_FEATURE, 425 }; 426 427 428 private static final String [] fgSAXProperties = { 429 DECLARATION_HANDLER_PROPERTY, 430 LEXICAL_HANDLER_PROPERTY, 431 DOM_NODE_PROPERTY, 432 XML_STRING_PROPERTY, 433 }; 434 435 436 private static final String [] fgXercesFeatures = { 437 SCHEMA_VALIDATION_FEATURE, 438 SCHEMA_FULL_CHECKING, 439 DYNAMIC_VALIDATION_FEATURE, 440 WARN_ON_DUPLICATE_ATTDEF_FEATURE, 441 WARN_ON_UNDECLARED_ELEMDEF_FEATURE, 442 ALLOW_JAVA_ENCODINGS_FEATURE, 443 CONTINUE_AFTER_FATAL_ERROR_FEATURE, 444 LOAD_DTD_GRAMMAR_FEATURE, 445 LOAD_EXTERNAL_DTD_FEATURE, 446 CREATE_ENTITY_REF_NODES_FEATURE, 448 INCLUDE_IGNORABLE_WHITESPACE, 449 DEFAULT_ATTRIBUTE_VALUES_FEATURE, 451 VALIDATE_CONTENT_MODELS_FEATURE, 452 VALIDATE_DATATYPES_FEATURE, 453 NOTIFY_CHAR_REFS_FEATURE, 454 NOTIFY_BUILTIN_REFS_FEATURE, 455 DISALLOW_DOCTYPE_DECL_FEATURE, 456 STANDARD_URI_CONFORMANT_FEATURE, 457 GENERATE_SYNTHETIC_ANNOTATIONS_FEATURE, 458 VALIDATE_ANNOTATIONS_FEATURE, 459 HONOUR_ALL_SCHEMALOCATIONS_FEATURE, 460 XINCLUDE_FEATURE, 461 XINCLUDE_FIXUP_BASE_URIS_FEATURE, 462 XINCLUDE_FIXUP_LANGUAGE_FEATURE 463 }; 464 465 466 private static final String [] fgXercesProperties = { 467 CURRENT_ELEMENT_NODE_PROPERTY, 468 DOCUMENT_CLASS_NAME_PROPERTY, 469 SYMBOL_TABLE_PROPERTY, 470 ERROR_HANDLER_PROPERTY, 471 ERROR_REPORTER_PROPERTY, 472 ENTITY_MANAGER_PROPERTY, 473 ENTITY_RESOLVER_PROPERTY, 474 XMLGRAMMAR_POOL_PROPERTY, 475 DATATYPE_VALIDATOR_FACTORY_PROPERTY, 476 DOCUMENT_SCANNER_PROPERTY, 477 DTD_SCANNER_PROPERTY, 478 VALIDATOR_PROPERTY, 479 SCHEMA_LOCATION, 480 SCHEMA_NONS_LOCATION, 481 VALIDATION_MANAGER_PROPERTY, 482 BUFFER_SIZE_PROPERTY, 483 SECURITY_MANAGER_PROPERTY 484 }; 485 486 487 private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object [] {}); 488 489 493 494 private Constants() {} 495 496 500 502 503 public static Enumeration getSAXFeatures() { 504 return fgSAXFeatures.length > 0 505 ? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration; 506 } 508 509 public static Enumeration getSAXProperties() { 510 return fgSAXProperties.length > 0 511 ? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration; 512 } 514 516 517 public static Enumeration getXercesFeatures() { 518 return fgXercesFeatures.length > 0 519 ? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration; 520 } 522 523 public static Enumeration getXercesProperties() { 524 return fgXercesProperties.length > 0 525 ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration; 526 } 528 532 537 static class ArrayEnumeration 538 implements Enumeration { 539 540 544 545 private Object [] array; 546 547 548 private int index; 549 550 554 555 public ArrayEnumeration(Object [] array) { 556 this.array = array; 557 } 559 563 570 public boolean hasMoreElements() { 571 return index < array.length; 572 } 574 581 public Object nextElement() { 582 if (index < array.length) { 583 return array[index++]; 584 } 585 throw new NoSuchElementException (); 586 } 588 } 590 594 595 public static void main(String [] argv) { 596 597 print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures); 598 print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties); 599 print("Xerces features:", XERCES_FEATURE_PREFIX, fgXercesFeatures); 600 print("Xerces properties:", XERCES_PROPERTY_PREFIX, fgXercesProperties); 601 602 } 604 605 private static void print(String header, String prefix, Object [] array) { 606 System.out.print(header); 607 if (array.length > 0) { 608 System.out.println(); 609 for (int i = 0; i < array.length; i++) { 610 System.out.print(" "); 611 System.out.print(prefix); 612 System.out.println(array[i]); 613 } 614 } 615 else { 616 System.out.println(" none."); 617 } 618 } 620 } | Popular Tags |