1. /*
  2. * The Apache Software License, Version 1.1
  3. *
  4. *
  5. * Copyright (c) 2000-2003 The Apache Software Foundation. All rights
  6. * reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. *
  12. * 1. Redistributions of source code must retain the above copyright
  13. * notice, this list of conditions and the following disclaimer.
  14. *
  15. * 2. Redistributions in binary form must reproduce the above copyright
  16. * notice, this list of conditions and the following disclaimer in
  17. * the documentation and/or other materials provided with the
  18. * distribution.
  19. *
  20. * 3. The end-user documentation included with the redistribution,
  21. * if any, must include the following acknowledgment:
  22. * "This product includes software developed by the
  23. * Apache Software Foundation (http://www.apache.org/)."
  24. * Alternately, this acknowledgment may appear in the software itself,
  25. * if and wherever such third-party acknowledgments normally appear.
  26. *
  27. * 4. The names "Xerces" and "Apache Software Foundation" must
  28. * not be used to endorse or promote products derived from this
  29. * software without prior written permission. For written
  30. * permission, please contact apache@apache.org.
  31. *
  32. * 5. Products derived from this software may not be called "Apache",
  33. * nor may "Apache" appear in their name, without prior written
  34. * permission of the Apache Software Foundation.
  35. *
  36. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  37. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  38. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  39. * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  40. * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  43. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  44. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  45. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  46. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  47. * SUCH DAMAGE.
  48. * ====================================================================
  49. *
  50. * This software consists of voluntary contributions made by many
  51. * individuals on behalf of the Apache Software Foundation and was
  52. * originally based on software copyright (c) 1999, International
  53. * Business Machines, Inc., http://www.apache.org. For more
  54. * information on the Apache Software Foundation, please see
  55. * <http://www.apache.org/>.
  56. */
  57. package com.sun.org.apache.xerces.internal.impl;
  58. import java.util.Enumeration;
  59. import java.util.NoSuchElementException;
  60. /**
  61. * Commonly used constants.
  62. *
  63. * @author Andy Clark, IBM
  64. *
  65. * @version $Id: Constants.java,v 1.42 2004/04/25 02:08:53 mrglavas Exp $
  66. */
  67. public final class Constants {
  68. //
  69. // Constants
  70. //
  71. // Schema Types:
  72. public static final String NS_XMLSCHEMA = "http://www.w3.org/2001/XMLSchema".intern();
  73. public static final String NS_DTD = "http://www.w3.org/TR/REC-xml".intern();
  74. // sax features
  75. /** SAX feature prefix ("http://xml.org/sax/features/"). */
  76. public static final String SAX_FEATURE_PREFIX = "http://xml.org/sax/features/";
  77. /** Namespaces feature ("namespaces"). */
  78. public static final String NAMESPACES_FEATURE = "namespaces";
  79. /** Namespace prefixes feature ("namespace-prefixes"). */
  80. public static final String NAMESPACE_PREFIXES_FEATURE = "namespace-prefixes";
  81. /** String interning feature ("string-interning"). */
  82. public static final String STRING_INTERNING_FEATURE = "string-interning";
  83. /** Validation feature ("validation"). */
  84. public static final String VALIDATION_FEATURE = "validation";
  85. /** External general entities feature ("external-general-entities "). */
  86. public static final String EXTERNAL_GENERAL_ENTITIES_FEATURE = "external-general-entities";
  87. /** External parameter entities feature ("external-parameter-entities "). */
  88. public static final String EXTERNAL_PARAMETER_ENTITIES_FEATURE = "external-parameter-entities";
  89. /** Lexical handler parameter entities feature ("lexical-handler/parameter-entities"). */
  90. public static final String LEXICAL_HANDLER_PARAMETER_ENTITIES_FEATURE = "lexical-handler/parameter-entities";
  91. /** Is standalone feature ("is-standalone"). */
  92. public static final String IS_STANDALONE_FEATURE = "is-standalone";
  93. /** Resolve DTD URIs feature ("resolve-dtd-uris"). */
  94. public static final String RESOLVE_DTD_URIS_FEATURE = "resolve-dtd-uris";
  95. /** Use Attributes2 feature ("use-attributes2"). */
  96. public static final String USE_ATTRIBUTES2_FEATURE = "use-attributes2";
  97. /** Use Locator2 feature ("use-locator2"). */
  98. public static final String USE_LOCATOR2_FEATURE = "use-locator2";
  99. /** Use EntityResolver2 feature ("use-entity-resolver2"). */
  100. public static final String USE_ENTITY_RESOLVER2_FEATURE = "use-entity-resolver2";
  101. /** Unicode normalization checking feature ("unicode-normalization-checking"). */
  102. public static final String UNICODE_NORMALIZATION_CHECKING_FEATURE = "unicode-normalization-checking";
  103. /** xmlns URIs feature ("xmlns-uris"). */
  104. public static final String XMLNS_URIS_FEATURE = "xmlns-uris";
  105. /** XML 1.1 feature ("xml-1.1"). */
  106. public static final String XML_11_FEATURE = "xml-1.1";
  107. /** Allow unparsed entity and notation declaration events to be sent after the end DTD event ("allow-dtd-events-after-endDTD") */
  108. public static final String ALLOW_DTD_EVENTS_AFTER_ENDDTD_FEATURE = "allow-dtd-events-after-endDTD";
  109. // sax properties
  110. /** SAX property prefix ("http://xml.org/sax/properties/"). */
  111. public static final String SAX_PROPERTY_PREFIX = "http://xml.org/sax/properties/";
  112. /** Declaration handler property ("declaration-handler"). */
  113. public static final String DECLARATION_HANDLER_PROPERTY = "declaration-handler";
  114. /** Lexical handler property ("lexical-handler"). */
  115. public static final String LEXICAL_HANDLER_PROPERTY = "lexical-handler";
  116. /** DOM node property ("dom-node"). */
  117. public static final String DOM_NODE_PROPERTY = "dom-node";
  118. /** XML string property ("xml-string"). */
  119. public static final String XML_STRING_PROPERTY = "xml-string";
  120. public static final String FEATURE_SECURE_PROCESSING = "http://javax.xml.XMLConstants/feature/secure-processing";
  121. /** Document XML version property ("document-xml-version"). */
  122. public static final String DOCUMENT_XML_VERSION_PROPERTY = "document-xml-version";
  123. //
  124. // JAXP properties
  125. //
  126. /** JAXP property prefix ("http://java.sun.com/xml/jaxp/properties/"). */
  127. public static final String JAXP_PROPERTY_PREFIX =
  128. "http://java.sun.com/xml/jaxp/properties/";
  129. /** JAXP schemaSource property: when used internally may include DTD sources (DOM) */
  130. public static final String SCHEMA_SOURCE = "schemaSource";
  131. /** JAXP schemaSource language: when used internally may include DTD namespace (DOM) */
  132. public static final String SCHEMA_LANGUAGE = "schemaLanguage";
  133. public static final String SYSTEM_PROPERTY_ELEMENT_ATTRIBUTE_LIMIT = "elementAttributeLimit" ;
  134. //
  135. // DOM features
  136. //
  137. /** Comments feature ("include-comments"). */
  138. public static final String INCLUDE_COMMENTS_FEATURE = "include-comments";
  139. /** Create cdata nodes feature ("create-cdata-nodes"). */
  140. public static final String CREATE_CDATA_NODES_FEATURE = "create-cdata-nodes";
  141. /** Feature id: load as infoset. */
  142. public static final String LOAD_AS_INFOSET = "load-as-infoset";
  143. //
  144. // Constants: DOM Level 3 feature ids
  145. //
  146. public static final String DOM_CANONICAL_FORM = "canonical-form";
  147. public static final String DOM_CDATA_SECTIONS ="cdata-sections";
  148. public static final String DOM_COMMENTS = "comments";
  149. // REVISIT: this feature seems to have no effect for Xerces
  150. public static final String DOM_CHARSET_OVERRIDES_XML_ENCODING =
  151. "charset-overrides-xml-encoding";
  152. public static final String DOM_DATATYPE_NORMALIZATION = "datatype-normalization";
  153. public static final String DOM_ENTITIES = "entities";
  154. public static final String DOM_INFOSET = "infoset";
  155. public static final String DOM_NAMESPACES = "namespaces";
  156. public static final String DOM_NAMESPACE_DECLARATIONS = "namespace-declarations";
  157. public static final String DOM_SUPPORTED_MEDIATYPES_ONLY =
  158. "supported-media-types-only";
  159. public static final String DOM_VALIDATE_IF_SCHEMA = "validate-if-schema";
  160. public static final String DOM_VALIDATE = "validate";
  161. public static final String DOM_ELEMENT_CONTENT_WHITESPACE =
  162. "element-content-whitespace";
  163. // DOM Level 3 features defined in Core:
  164. public static final String DOM_DISCARD_DEFAULT_CONTENT = "discard-default-content";
  165. public static final String DOM_NORMALIZE_CHARACTERS = "normalize-characters";
  166. public static final String DOM_CHECK_CHAR_NORMALIZATION = "check-character-normalization";
  167. public static final String DOM_WELLFORMED = "well-formed";
  168. public static final String DOM_SPLIT_CDATA = "split-cdata-sections";
  169. // Load and Save
  170. public static final String DOM_FORMAT_PRETTY_PRINT = "format-pretty-print";
  171. public static final String DOM_XMLDECL = "xml-declaration";
  172. public static final String DOM_UNKNOWNCHARS = "unknown-characters";
  173. public static final String DOM_CERTIFIED = "certified";
  174. public static final String DOM_DISALLOW_DOCTYPE = "disallow-doctype";
  175. public static final String DOM_IGNORE_UNKNOWN_CHARACTER_DENORMALIZATIONS = "ignore-unknown-character-denormalizations";
  176. // DOM Properties
  177. public static final String DOM_RESOURCE_RESOLVER = "resource-resolver";
  178. public static final String DOM_ERROR_HANDLER = "error-handler";
  179. public static final String DOM_SCHEMA_TYPE = "schema-type";
  180. public static final String DOM_SCHEMA_LOCATION = "schema-location";
  181. // XSModel
  182. public static final String DOM_PSVI = "psvi";
  183. // xerces features
  184. /** Xerces features prefix ("http://apache.org/xml/features/"). */
  185. public static final String XERCES_FEATURE_PREFIX = "http://apache.org/xml/features/";
  186. /** Schema validation feature ("validation/schema"). */
  187. public static final String SCHEMA_VALIDATION_FEATURE = "validation/schema";
  188. /** Expose schema normalized values */
  189. public static final String SCHEMA_NORMALIZED_VALUE = "validation/schema/normalized-value";
  190. /** Send schema default value via characters() */
  191. public static final String SCHEMA_ELEMENT_DEFAULT = "validation/schema/element-default";
  192. /** Schema full constraint checking ("validation/schema-full-checking"). */
  193. public static final String SCHEMA_FULL_CHECKING = "validation/schema-full-checking";
  194. /** Augment Post-Schema-Validation-Infoset */
  195. public static final String SCHEMA_AUGMENT_PSVI = "validation/schema/augment-psvi";
  196. /** Dynamic validation feature ("validation/dynamic"). */
  197. public static final String DYNAMIC_VALIDATION_FEATURE = "validation/dynamic";
  198. /** Warn on duplicate attribute declaration feature ("validation/warn-on-duplicate-attdef"). */
  199. public static final String WARN_ON_DUPLICATE_ATTDEF_FEATURE = "validation/warn-on-duplicate-attdef";
  200. /** Warn on undeclared element feature ("validation/warn-on-undeclared-elemdef"). */
  201. public static final String WARN_ON_UNDECLARED_ELEMDEF_FEATURE = "validation/warn-on-undeclared-elemdef";
  202. /** Warn on duplicate entity declaration feature ("warn-on-duplicate-entitydef"). */
  203. public static final String WARN_ON_DUPLICATE_ENTITYDEF_FEATURE = "warn-on-duplicate-entitydef";
  204. /** Allow Java encoding names feature ("allow-java-encodings"). */
  205. public static final String ALLOW_JAVA_ENCODINGS_FEATURE = "allow-java-encodings";
  206. /** Disallow DOCTYPE declaration feature ("disallow-doctype-decl"). */
  207. public static final String DISALLOW_DOCTYPE_DECL_FEATURE = "disallow-doctype-decl";
  208. /** Continue after fatal error feature ("continue-after-fatal-error"). */
  209. public static final String CONTINUE_AFTER_FATAL_ERROR_FEATURE = "continue-after-fatal-error";
  210. /** Load dtd grammar when nonvalidating feature ("nonvalidating/load-dtd-grammar"). */
  211. public static final String LOAD_DTD_GRAMMAR_FEATURE = "nonvalidating/load-dtd-grammar";
  212. /** Load external dtd when nonvalidating feature ("nonvalidating/load-external-dtd"). */
  213. public static final String LOAD_EXTERNAL_DTD_FEATURE = "nonvalidating/load-external-dtd";
  214. /** Defer node expansion feature ("dom/defer-node-expansion"). */
  215. public static final String DEFER_NODE_EXPANSION_FEATURE = "dom/defer-node-expansion";
  216. /** Create entity reference nodes feature ("dom/create-entity-ref-nodes"). */
  217. public static final String CREATE_ENTITY_REF_NODES_FEATURE = "dom/create-entity-ref-nodes";
  218. /** Include ignorable whitespace feature ("dom/include-ignorable-whitespace"). */
  219. public static final String INCLUDE_IGNORABLE_WHITESPACE = "dom/include-ignorable-whitespace";
  220. /** Default attribute values feature ("validation/default-attribute-values"). */
  221. public static final String DEFAULT_ATTRIBUTE_VALUES_FEATURE = "validation/default-attribute-values";
  222. /** Validate content models feature ("validation/validate-content-models"). */
  223. public static final String VALIDATE_CONTENT_MODELS_FEATURE = "validation/validate-content-models";
  224. /** Validate datatypes feature ("validation/validate-datatypes"). */
  225. public static final String VALIDATE_DATATYPES_FEATURE = "validation/validate-datatypes";
  226. /** Notify character references feature (scanner/notify-char-refs"). */
  227. public static final String NOTIFY_CHAR_REFS_FEATURE = "scanner/notify-char-refs";
  228. /** Notify built-in (&amp;, etc.) references feature (scanner/notify-builtin-refs"). */
  229. public static final String NOTIFY_BUILTIN_REFS_FEATURE = "scanner/notify-builtin-refs";
  230. /** Standard URI conformant feature ("standard-uri-conformant"). */
  231. public static final String STANDARD_URI_CONFORMANT_FEATURE = "standard-uri-conformant";
  232. /** Internal performance related feature:
  233. * false - the parser settings (features/properties) have not changed between 2 parses
  234. * true - the parser settings have changed between 2 parses
  235. * NOTE: this feature should only be set by the parser configuration.
  236. */
  237. public static final String PARSER_SETTINGS = "internal/parser-settings";
  238. /** Feature to make XML Processor XInclude Aware */
  239. public static final String XINCLUDE_AWARE = "xinclude-aware";
  240. /** Ignore xsi:schemaLocation and xsi:noNamespaceSchemaLocation. */
  241. public static final String IGNORE_SCHEMA_LOCATION_HINTS = "validation/schema/ignore-schema-location-hints";
  242. /**
  243. * When true, the schema processor will change characters events
  244. * to ignorableWhitespaces events, when characters are expected to
  245. * only contain ignorable whitespaces.
  246. */
  247. public static final String CHANGE_IGNORABLE_CHARACTERS_INTO_IGNORABLE_WHITESPACES =
  248. "validation/change-ignorable-characters-into-ignorable-whitespaces";
  249. // xerces properties
  250. /** Xerces properties prefix ("http://apache.org/xml/properties/"). */
  251. public static final String XERCES_PROPERTY_PREFIX = "http://apache.org/xml/properties/";
  252. /** Current element node property ("dom/current-element-node"). */
  253. public static final String CURRENT_ELEMENT_NODE_PROPERTY = "dom/current-element-node";
  254. /** Document class name property ("dom/document-class-name"). */
  255. public static final String DOCUMENT_CLASS_NAME_PROPERTY = "dom/document-class-name";
  256. /** Symbol table property ("internal/symbol-table"). */
  257. public static final String SYMBOL_TABLE_PROPERTY = "internal/symbol-table";
  258. /** Error reporter property ("internal/error-reporter"). */
  259. public static final String ERROR_REPORTER_PROPERTY = "internal/error-reporter";
  260. /** Error handler property ("internal/error-handler"). */
  261. public static final String ERROR_HANDLER_PROPERTY = "internal/error-handler";
  262. /** XInclude handler property ("internal/xinclude-handler"). */
  263. public static final String XINCLUDE_HANDLER_PROPERTY = "internal/xinclude-handler";
  264. /** Entity manager property ("internal/entity-manager"). */
  265. public static final String ENTITY_MANAGER_PROPERTY = "internal/entity-manager";
  266. /** Input buffer size property ("input-buffer-size"). */
  267. public static final String BUFFER_SIZE_PROPERTY = "input-buffer-size";
  268. /** Security manager property ("security-manager"). */
  269. public static final String SECURITY_MANAGER_PROPERTY = "security-manager";
  270. /** property identifier: security manager. */
  271. protected static final String SECURITY_MANAGER =
  272. Constants.XERCES_PROPERTY_PREFIX + Constants.SECURITY_MANAGER_PROPERTY;
  273. /** Entity resolver property ("internal/entity-resolver"). */
  274. public static final String ENTITY_RESOLVER_PROPERTY = "internal/entity-resolver";
  275. /** Grammar pool property ("internal/grammar-pool"). */
  276. public static final String XMLGRAMMAR_POOL_PROPERTY = "internal/grammar-pool";
  277. /** Datatype validator factory ("internal/datatype-validator-factory"). */
  278. public static final String DATATYPE_VALIDATOR_FACTORY_PROPERTY = "internal/datatype-validator-factory";
  279. /** Document scanner property ("internal/document-scanner"). */
  280. public static final String DOCUMENT_SCANNER_PROPERTY = "internal/document-scanner";
  281. /** DTD scanner property ("internal/dtd-scanner"). */
  282. public static final String DTD_SCANNER_PROPERTY = "internal/dtd-scanner";
  283. /** DTD processor property ("internal/dtd-processor"). */
  284. public static final String DTD_PROCESSOR_PROPERTY = "internal/dtd-processor";
  285. /** Validator property ("internal/validator"). */
  286. public static final String VALIDATOR_PROPERTY = "internal/validator";
  287. /** Validator property ("internal/validator/dtd"). */
  288. public static final String DTD_VALIDATOR_PROPERTY = "internal/validator/dtd";
  289. /** Validator property ("internal/validator/schema"). */
  290. public static final String SCHEMA_VALIDATOR_PROPERTY = "internal/validator/schema";
  291. /** No namespace schema location property ("schema/external-schemaLocation"). */
  292. public static final String SCHEMA_LOCATION = "schema/external-schemaLocation";
  293. /** Schema location property ("schema/external-noNamespaceSchemaLocation"). */
  294. public static final String SCHEMA_NONS_LOCATION = "schema/external-noNamespaceSchemaLocation";
  295. /** Namespace binder property ("internal/namespace-binder"). */
  296. public static final String NAMESPACE_BINDER_PROPERTY = "internal/namespace-binder";
  297. /** Namespace context property ("internal/namespace-context"). */
  298. public static final String NAMESPACE_CONTEXT_PROPERTY = "internal/namespace-context";
  299. /** Validation manager property ("internal/validation-manager"). */
  300. public static final String VALIDATION_MANAGER_PROPERTY = "internal/validation-manager";
  301. /** XPointer Schema property ("xpointer-schema"). */
  302. public static final String XPOINTER_SCHEMA_PROPERTY = "xpointer-schema";
  303. // general constants
  304. /** Element PSVI is stored in augmentations using string "ELEMENT_PSVI" */
  305. public final static String ELEMENT_PSVI = "ELEMENT_PSVI";
  306. /* Attribute PSVI is stored in augmentations using string "ATTRIBUTE_PSVI" */
  307. public final static String ATTRIBUTE_PSVI = "ATTRIBUTE_PSVI";
  308. /**
  309. * Boolean indicating whether an attribute is declared in the DTD is stored
  310. * in augmentations using the string "ATTRIBUTE_DECLARED". The absence of this
  311. * augmentation indicates that the attribute was not declared in the DTD.
  312. */
  313. public final static String ATTRIBUTE_DECLARED = "ATTRIBUTE_DECLARED";
  314. public final static String ENTITY_EXPANSION_LIMIT = "entityExpansionLimit";
  315. public final static String MAX_OCCUR_LIMIT = "maxOccurLimit";
  316. /**
  317. * {@link org.w3c.dom.TypeInfo} associated with current element/attribute
  318. * is stored in augmentations using this string as the key.
  319. *
  320. * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser}
  321. * regarding what object the DOM will return from
  322. * {@link org.w3c.dom.Attr#getSchemaTypeInfo()} and
  323. * {@link org.w3c.dom.Element#getSchemaTypeInfo()} and
  324. */
  325. public final static String TYPEINFO = "org.w3c.dom.TypeInfo";
  326. /**
  327. * Whether an attribute is an id or not is stored in augmentations
  328. * using this string as the key. The value is {@link Boolean#TRUE}
  329. * or {@link Boolean#FALSE}.
  330. *
  331. * This will ultimately controls {@link com.sun.org.apache.xerces.internal.parsers.AbstractDOMParser}
  332. * about whether it will mark an attribute as ID or not.
  333. */
  334. public final static String ID_ATTRIBUTE = "ID_ATTRIBUTE";
  335. // XML version constants
  336. /**
  337. * Boolean indicating whether an entity referenced in the document has
  338. * not been read is stored in augmentations using the string "ENTITY_SKIPPED".
  339. * The absence of this augmentation indicates that the entity had a
  340. * declaration and was expanded.
  341. */
  342. public final static String ENTITY_SKIPPED = "ENTITY_SKIPPED";
  343. /**
  344. * Boolean indicating whether a character is a probable white space
  345. * character (ch <= 0x20) that was the replacement text of a character
  346. * reference is stored in augmentations using the string "CHAR_REF_PROBABLE_WS".
  347. * The absence of this augmentation indicates that the character is not
  348. * probable white space and/or was not included from a character reference.
  349. */
  350. public final static String CHAR_REF_PROBABLE_WS = "CHAR_REF_PROBABLE_WS";
  351. // XML version constants
  352. public final static short XML_VERSION_1_0 = 1;
  353. public final static short XML_VERSION_1_1 = 2;
  354. // DOM related constants
  355. public final static String ANONYMOUS_TYPE_NAMESPACE =
  356. "http://apache.org/xml/xmlschema/1.0/anonymousTypes";
  357. // private
  358. /** SAX features. */
  359. private static final String[] fgSAXFeatures = {
  360. NAMESPACES_FEATURE,
  361. NAMESPACE_PREFIXES_FEATURE,
  362. STRING_INTERNING_FEATURE,
  363. VALIDATION_FEATURE,
  364. EXTERNAL_GENERAL_ENTITIES_FEATURE,
  365. EXTERNAL_PARAMETER_ENTITIES_FEATURE,
  366. };
  367. /** SAX properties. */
  368. private static final String[] fgSAXProperties = {
  369. DECLARATION_HANDLER_PROPERTY,
  370. LEXICAL_HANDLER_PROPERTY,
  371. DOM_NODE_PROPERTY,
  372. XML_STRING_PROPERTY,
  373. };
  374. /** Xerces features. */
  375. private static final String[] fgXercesFeatures = {
  376. SCHEMA_VALIDATION_FEATURE,
  377. SCHEMA_FULL_CHECKING,
  378. DYNAMIC_VALIDATION_FEATURE,
  379. WARN_ON_DUPLICATE_ATTDEF_FEATURE,
  380. WARN_ON_UNDECLARED_ELEMDEF_FEATURE,
  381. ALLOW_JAVA_ENCODINGS_FEATURE,
  382. CONTINUE_AFTER_FATAL_ERROR_FEATURE,
  383. LOAD_DTD_GRAMMAR_FEATURE,
  384. LOAD_EXTERNAL_DTD_FEATURE,
  385. //DEFER_NODE_EXPANSION_FEATURE,
  386. CREATE_ENTITY_REF_NODES_FEATURE,
  387. XINCLUDE_AWARE,
  388. INCLUDE_IGNORABLE_WHITESPACE,
  389. //GRAMMAR_ACCESS_FEATURE,
  390. DEFAULT_ATTRIBUTE_VALUES_FEATURE,
  391. VALIDATE_CONTENT_MODELS_FEATURE,
  392. VALIDATE_DATATYPES_FEATURE,
  393. NOTIFY_CHAR_REFS_FEATURE,
  394. NOTIFY_BUILTIN_REFS_FEATURE,
  395. DISALLOW_DOCTYPE_DECL_FEATURE,
  396. STANDARD_URI_CONFORMANT_FEATURE
  397. };
  398. /** Xerces properties. */
  399. private static final String[] fgXercesProperties = {
  400. CURRENT_ELEMENT_NODE_PROPERTY,
  401. DOCUMENT_CLASS_NAME_PROPERTY,
  402. SYMBOL_TABLE_PROPERTY,
  403. ERROR_HANDLER_PROPERTY,
  404. ERROR_REPORTER_PROPERTY,
  405. ENTITY_MANAGER_PROPERTY,
  406. ENTITY_RESOLVER_PROPERTY,
  407. XMLGRAMMAR_POOL_PROPERTY,
  408. DATATYPE_VALIDATOR_FACTORY_PROPERTY,
  409. DOCUMENT_SCANNER_PROPERTY,
  410. DTD_SCANNER_PROPERTY,
  411. VALIDATOR_PROPERTY,
  412. SCHEMA_LOCATION,
  413. SCHEMA_NONS_LOCATION,
  414. VALIDATION_MANAGER_PROPERTY,
  415. BUFFER_SIZE_PROPERTY,
  416. SECURITY_MANAGER_PROPERTY
  417. };
  418. /** Empty enumeration. */
  419. private static final Enumeration fgEmptyEnumeration = new ArrayEnumeration(new Object[] {});
  420. //
  421. // Constructors
  422. //
  423. /** This class cannot be instantiated. */
  424. private Constants() {}
  425. //
  426. // Public methods
  427. //
  428. // sax
  429. /** Returns an enumeration of the SAX features. */
  430. public static Enumeration getSAXFeatures() {
  431. return fgSAXFeatures.length > 0
  432. ? new ArrayEnumeration(fgSAXFeatures) : fgEmptyEnumeration;
  433. } // getSAXFeatures():Enumeration
  434. /** Returns an enumeration of the SAX properties. */
  435. public static Enumeration getSAXProperties() {
  436. return fgSAXProperties.length > 0
  437. ? new ArrayEnumeration(fgSAXProperties) : fgEmptyEnumeration;
  438. } // getSAXProperties():Enumeration
  439. // xerces
  440. /** Returns an enumeration of the Xerces features. */
  441. public static Enumeration getXercesFeatures() {
  442. return fgXercesFeatures.length > 0
  443. ? new ArrayEnumeration(fgXercesFeatures) : fgEmptyEnumeration;
  444. } // getXercesFeatures():Enumeration
  445. /** Returns an enumeration of the Xerces properties. */
  446. public static Enumeration getXercesProperties() {
  447. return fgXercesProperties.length > 0
  448. ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration;
  449. } // getXercesProperties():Enumeration
  450. //
  451. // Classes
  452. //
  453. /**
  454. * An array enumeration.
  455. *
  456. * @author Andy Clark, IBM
  457. */
  458. static class ArrayEnumeration
  459. implements Enumeration {
  460. //
  461. // Data
  462. //
  463. /** Array. */
  464. private Object[] array;
  465. /** Index. */
  466. private int index;
  467. //
  468. // Constructors
  469. //
  470. /** Constructs an array enumeration. */
  471. public ArrayEnumeration(Object[] array) {
  472. this.array = array;
  473. } // <init>(Object[])
  474. //
  475. // Enumeration methods
  476. //
  477. /**
  478. * Tests if this enumeration contains more elements.
  479. *
  480. * @return <code>true</code> if this enumeration contains more elements;
  481. * <code>false</code> otherwise.
  482. * @since JDK1.0
  483. */
  484. public boolean hasMoreElements() {
  485. return index < array.length;
  486. } // hasMoreElement():boolean
  487. /**
  488. * Returns the next element of this enumeration.
  489. *
  490. * @return the next element of this enumeration.
  491. * @exception NoSuchElementException if no more elements exist.
  492. * @since JDK1.0
  493. */
  494. public Object nextElement() {
  495. if (index < array.length) {
  496. return array[index++];
  497. }
  498. throw new NoSuchElementException();
  499. } // nextElement():Object
  500. } // class ArrayEnumeration
  501. //
  502. // MAIN
  503. //
  504. /** Prints all of the constants to standard output. */
  505. public static void main(String[] argv) {
  506. print("SAX features:", SAX_FEATURE_PREFIX, fgSAXFeatures);
  507. print("SAX properties:", SAX_PROPERTY_PREFIX, fgSAXProperties);
  508. print("Xerces features:", XERCES_FEATURE_PREFIX, fgXercesFeatures);
  509. print("Xerces properties:", XERCES_PROPERTY_PREFIX, fgXercesProperties);
  510. } // main(String[])
  511. /** Prints a list of features/properties. */
  512. private static void print(String header, String prefix, Object[] array) {
  513. System.out.print(header);
  514. if (array.length > 0) {
  515. System.out.println();
  516. for (int i = 0; i < array.length; i++) {
  517. System.out.print(" ");
  518. System.out.print(prefix);
  519. System.out.println(array[i]);
  520. }
  521. }
  522. else {
  523. System.out.println(" none.");
  524. }
  525. } // print(String,String,Object[])
  526. } // class Constants