Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/apache/xerces/dom3/DOMConfiguration.java


1   /*
2    * Copyright (c) 2003 World Wide Web Consortium,
3    *
4    * (Massachusetts Institute of Technology, European Research Consortium for
5    * Informatics and Mathematics, Keio University). All Rights Reserved. This
6    * work is distributed under the W3C(r) Software License [1] in the hope that
7    * it will be useful, but WITHOUT ANY WARRANTY; without even the implied
8    * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9    *
10   * [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
11   */
12  
13  package org.apache.xerces.dom3;
14  
15  import org.w3c.dom.DOMException;
16  import org.apache.xerces.dom3.DOMStringList;
17  
18  /**
19   *  The <code>DOMConfiguration</code> interface represents the configuration 
20   * of a document and maintains a table of recognized parameters. Using the 
21   * configuration, it is possible to change 
22   * <code>Document.normalizeDocument()</code> behavior, such as replacing the 
23   * <code>CDATASection</code> nodes with <code>Text</code> nodes or 
24   * specifying the type of the schema that must be used when the validation 
25   * of the <code>Document</code> is requested. <code>DOMConfiguration</code> 
26   * objects are also used in [<a href='http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107'>DOM Level 3 Load and Save</a>]
27   *  in the <code>DOMParser</code> and <code>DOMSerializer</code> interfaces. 
28   * <p> The parameter names used by the <code>DOMConfiguration</code> object 
29   * are defined throughout the DOM Level 3 specifications. Names are 
30   * case-insensitives. To avoid possible conflicts, as a convention, names 
31   * referring to parameters defined outside the DOM specification should be 
32   * made unique. Because parameters are exposed as properties in the , names 
33   * are recommended to follow the section 5.16 Identifiers of [Unicode] with the addition of the character '-' (HYPHEN-MINUS) but it is not 
34   * enforced by the DOM implementation. DOM Level 3 Core Implementations are 
35   * required to recognize all parameters defined in this specification. Some 
36   * parameter values may also be required to be supported by the 
37   * implementation. Refer to the definition of the parameter to know if a 
38   * value must be supported or not. 
39   * <p ><b>Note:</b>  Parameters are similar to features and properties used in 
40   * SAX2 [<a href='http://www.saxproject.org/'>SAX</a>]. 
41   * <p> The following list of parameters defined in the DOM: 
42   * <dl>
43   * <dt>
44   * <code>"canonical-form"</code></dt>
45   * <dd>
46   * <dl>
47   * <dt><code>true</code></dt>
48   * <dd>[<em>optional</em>]Canonicalize the document according to the rules specified in [<a href='http://www.w3.org/TR/2001/REC-xml-c14n-20010315'>Canonical XML</a>]. 
49   * Note that this is limited to what can be represented in the DOM. In 
50   * particular, there is no way to specify the order of the attributes in the 
51   * DOM.This forces the following parameters to <code>false</code>: "entities
52   * ", "normalize-characters", "cdata-sections".This forces the following 
53   * parameters to <code>true</code>: "namespaces", "namespace-declarations", "
54   * well-formed", "element-content-whitespace".Other parameters are not 
55   * changed unless explicitly specified in the description of the parameters. 
56   * In addition, the <code>DocumentType</code> node is removed from the tree 
57   * if any and superfluous namespace declarations are removed from each 
58   * element. Note that querying this parameter with <code>getParameter</code> 
59   * cannot return <code>true</code> unless it has been set to 
60   * <code>true</code> and the parameters described above are appropriately 
61   * set.</dd>
62   * <dt><code>false</code></dt>
63   * <dd>[<em>required</em>] (<em>default</em>)Do not canonicalize the document.</dd>
64   * </dl></dd>
65   * <dt><code>"cdata-sections"</code></dt>
66   * <dd>
67   * <dl>
68   * <dt>
69   * <code>true</code></dt>
70   * <dd>[<em>required</em>] (<em>default</em>)Keep <code>CDATASection</code> nodes in the document.</dd>
71   * <dt><code>false</code></dt>
72   * <dd>[<em>required</em>]Transform <code>CDATASection</code> nodes in the document into 
73   * <code>Text</code> nodes. The new <code>Text</code> node is then combined 
74   * with any adjacent <code>Text</code> node.</dd>
75   * </dl></dd>
76   * <dt>
77   * <code>"check-character-normalization"</code></dt>
78   * <dd>
79   * <dl>
80   * <dt><code>true</code></dt>
81   * <dd>[<em>optional</em>] Check if the characters in the document are fully normalized according 
82   * to the rules defined in [<a href='http://www.w3.org/TR/2003/WD-charmod-20030822/'>CharModel</a>] 
83   * supplemented by the definitions of relevant constructs from <a href='http://www.w3.org/TR/2003/PR-xml11-20031105/#sec-normalization-checking'>
84   * Section 2.13</a> of [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>]. </dd>
85   * <dt>
86   * <code>false</code></dt>
87   * <dd>[<em>required</em>] (<em>default</em>)Do not check if characters are normalized.</dd>
88   * </dl></dd>
89   * <dt><code>"comments"</code></dt>
90   * <dd>
91   * <dl>
92   * <dt>
93   * <code>true</code></dt>
94   * <dd>[<em>required</em>] (<em>default</em>)Keep <code>Comment</code> nodes in the document.</dd>
95   * <dt><code>false</code></dt>
96   * <dd>[<em>required</em>]Discard <code>Comment</code> nodes in the document.</dd>
97   * </dl></dd>
98   * <dt>
99   * <code>"datatype-normalization"</code></dt>
100  * <dd>
101  * <dl>
102  * <dt><code>true</code></dt>
103  * <dd>[<em>optional</em>] Exposed schema-normalized values in the tree. Since this parameter 
104  * requires to have schema information, the "validate" parameter will also 
105  * be set to <code>true</code>. Having this parameter activated when 
106  * "validate" is <code>false</code> has no effect and no 
107  * schema-normalization will happen. 
108  * <p ><b>Note:</b>  Since the document contains the result of the XML 1.0 
109  * processing, this parameter does not apply to attribute value 
110  * normalization as defined in section 3.3.3 of [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>] and is only 
111  * meant for schema languages other than Document Type Definition (DTD). </dd>
112  * <dt>
113  * <code>false</code></dt>
114  * <dd>[<em>required</em>] (<em>default</em>) Do not perform schema normalization on the tree. </dd>
115  * </dl></dd>
116  * <dt><code>"entities"</code></dt>
117  * <dd>
118  * <dl>
119  * <dt>
120  * <code>true</code></dt>
121  * <dd>[<em>required</em>] (<em>default</em>)Keep <code>EntityReference</code> and <code>Entity</code> nodes in the 
122  * document.</dd>
123  * <dt><code>false</code></dt>
124  * <dd>[<em>required</em>] Remove all <code>EntityReference</code> and <code>Entity</code> nodes 
125  * from the document, putting the entity expansions directly in their place. 
126  * <code>Text</code> nodes are normalized, as defined in 
127  * <code>Node.normalize</code>. Only <code>EntityReference</code> nodes to 
128  * non-defined entities are kept in the document, with their associated 
129  * <code>Entity</code> nodes if any. </dd>
130  * </dl></dd>
131  * <dt><code>"error-handler"</code></dt>
132  * <dd>[<em>required</em>] Contains a <code>DOMErrorHandler</code> object. If an error is 
133  * encountered in the document, the implementation will call back the 
134  * <code>DOMErrorHandler</code> registered using this parameter. The 
135  * implementation may provide a default <code>DOMErrorHandler</code> object. 
136  *  When called, <code>DOMError.relatedData</code> will contain the closest 
137  * node to where the error occurred. If the implementation is unable to 
138  * determine the node where the error occurs, 
139  * <code>DOMError.relatedData</code> will contain the <code>Document</code> 
140  * node. Mutations to the document from within an error handler will result 
141  * in implementation dependent behavior. </dd>
142  * <dt><code>"infoset"</code></dt>
143  * <dd>
144  * <dl>
145  * <dt>
146  * <code>true</code></dt>
147  * <dd>[<em>required</em>]Keep in the document the information defined in the XML Information Set [<a href='http://www.w3.org/TR/2001/REC-xml-infoset-20011024/'>XML Information Set</a>]
148  * .This forces the following parameters to <code>false</code>: "
149  * validate-if-schema", "entities", "datatype-normalization", "cdata-sections
150  * ".This forces the following parameters to <code>true</code>: "
151  * namespace-declarations", "well-formed", "element-content-whitespace", "
152  * comments", "namespaces".Other parameters are not changed unless 
153  * explicitly specified in the description of the parameters. Note that 
154  * querying this parameter with <code>getParameter</code> returns 
155  * <code>true</code> only if the individual parameters specified above are 
156  * appropriately set.</dd>
157  * <dt><code>false</code></dt>
158  * <dd>Setting <code>infoset</code> to 
159  * <code>false</code> has no effect.</dd>
160  * </dl></dd>
161  * <dt><code>"namespaces"</code></dt>
162  * <dd>
163  * <dl>
164  * <dt>
165  * <code>true</code></dt>
166  * <dd>[<em>required</em>] (<em>default</em>) Perform the namespace processing as defined in . </dd>
167  * <dt><code>false</code></dt>
168  * <dd>[<em>optional</em>] Do not perform the namespace processing. </dd>
169  * </dl></dd>
170  * <dt>
171  * <code>"namespace-declarations"</code></dt>
172  * <dd>
173  * <dl>
174  * <dt><code>true</code></dt>
175  * <dd>[<em>required</em>] (<em>default</em>) Include namespace declaration attributes, specified or defaulted from 
176  * the schema, in the document. See also the sections "Declaring Namespaces" 
177  * in [<a href='http://www.w3.org/TR/1999/REC-xml-names-19990114/'>XML Namespaces</a>]
178  *  and [<a href='http://www.w3.org/TR/2003/PR-xml-names11-20031105/'>XML Namespaces 1.1</a>]
179  * .</dd>
180  * <dt><code>false</code></dt>
181  * <dd>[<em>required</em>]Discard all namespace declaration attributes. The namespace prefixes (
182  * <code>Node.prefix</code>) are retained even if this parameter is set to 
183  * <code>false</code>.</dd>
184  * </dl></dd>
185  * <dt><code>"normalize-characters"</code></dt>
186  * <dd>
187  * <dl>
188  * <dt><code>true</code></dt>
189  * <dd>[<em>optional</em>] Fully normalize the characters in the document according to the rules 
190  * defined in [<a href='http://www.w3.org/TR/2003/WD-charmod-20030822/'>CharModel</a>] 
191  * supplemented by the definitions of relevant constructs from <a href='http://www.w3.org/TR/2003/PR-xml11-20031105/#sec-normalization-checking'>
192  * Section 2.13</a> of [<a href='http://www.w3.org/TR/2003/PR-xml11-20031105/'>XML 1.1</a>]. </dd>
193  * <dt>
194  * <code>false</code></dt>
195  * <dd>[<em>required</em>] (<em>default</em>)Do not perform character normalization.</dd>
196  * </dl></dd>
197  * <dt><code>"schema-location"</code></dt>
198  * <dd>[<em>optional</em>] Represent a <code>DOMString</code> object containing a list of URIs, 
199  * separated by whitespaces (characters matching the <a href='http://www.w3.org/TR/2000/REC-xml-20001006#NT-S'>nonterminal 
200  * production S</a> defined in section 2.3 [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>]), that 
201  * represents the schemas against which validation should occur, i.e. the 
202  * current schema. The types of schemas referenced in this list must match 
203  * the type specified with <code>schema-type</code>, otherwise the behavior 
204  * of an implementation is undefined.  The schemas specified using this 
205  * property take precedence to the schema information specified in the 
206  * document itself. For namespace aware schema, if a schema specified using 
207  * this property and a schema specified in the document instance (i.e. using 
208  * the <code>schemaLocation</code> attribute) in a schema document (i.e. 
209  * using schema <code>import</code> mechanisms) share the same 
210  * <code>targetNamespace</code>, the schema specified by the user using this 
211  * property will be used. If two schemas specified using this property share 
212  * the same <code>targetNamespace</code> or have no namespace, the behavior 
213  * is implementation dependent.  If no location has been provided, this 
214  * parameter is <code>null</code>. 
215  * <p ><b>Note:</b>  The <code>"schema-location"</code> parameter is ignored 
216  * unless the "schema-type" parameter value is set. It is strongly 
217  * recommended that <code>Document.documentURI</code> will be set so that an 
218  * implementation can successfully resolve any external entities referenced. </dd>
219  * <dt>
220  * <code>"schema-type"</code></dt>
221  * <dd>[<em>optional</em>] Represent a <code>DOMString</code> object containing an absolute URI 
222  * and representing the type of the schema language used to validate a 
223  * document against. Note that no lexical checking is done on the absolute 
224  * URI.  If this parameter is not set, a default value may be provided by 
225  * the implementation, based on the schema languages supported and on the 
226  * schema language used at load time. If no value is provided, this 
227  * parameter is <code>null</code>. 
228  * <p ><b>Note:</b>  For XML Schema [<a href='http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/'>XML Schema Part 1</a>]
229  * , applications must use the value 
230  * <code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>], 
231  * applications must use the value 
232  * <code>"http://www.w3.org/TR/REC-xml"</code>. Other schema languages are 
233  * outside the scope of the W3C and therefore should recommend an absolute 
234  * URI in order to use this method. </dd>
235  * <dt><code>"split-cdata-sections"</code></dt>
236  * <dd>
237  * <dl>
238  * <dt>
239  * <code>true</code></dt>
240  * <dd>[<em>required</em>] (<em>default</em>)Split CDATA sections containing the CDATA section termination marker 
241  * ']]&gt;'. When a CDATA section is split a warning is issued with a 
242  * <code>DOMError.type</code> equals to 
243  * <code>"cdata-sections-splitted"</code> and 
244  * <code>DOMError.relatedData</code> equals to the first 
245  * <code>CDATASection</code> node in document order resulting from the split.</dd>
246  * <dt>
247  * <code>false</code></dt>
248  * <dd>[<em>required</em>]Signal an error if a <code>CDATASection</code> contains an 
249  * unrepresentable character.</dd>
250  * </dl></dd>
251  * <dt><code>"validate"</code></dt>
252  * <dd>
253  * <dl>
254  * <dt><code>true</code></dt>
255  * <dd>[<em>optional</em>] Require the validation against a schema (i.e. XML schema, DTD, any 
256  * other type or representation of schema) of the document as it is being 
257  * normalized as defined by [<a href='http://www.w3.org/TR/2000/REC-xml-20001006'>XML 1.0</a>]. If 
258  * validation errors are found, or no schema was found, the error handler is 
259  * notified. Schema-normalized values will not be exposed according to the 
260  * schema in used unless the parameter "datatype-normalization" is 
261  * <code>true</code>.  This parameter will reevaluate: 
262  * <ul>
263  * <li> Attribute nodes with 
264  * <code>Attr.specified</code> equals to <code>false</code>, as specified in 
265  * the description of the <code>Attr</code> interface; 
266  * </li>
267  * <li> The value of the 
268  * attribute <code>Text.isElementContentWhitespace</code> for all 
269  * <code>Text</code> nodes; 
270  * </li>
271  * <li> The value of the attribute 
272  * <code>Attr.isId</code> for all <code>Attr</code> nodes; 
273  * </li>
274  * <li> The attributes 
275  * <code>Element.schemaTypeInfo</code> and <code>Attr.schemaTypeInfo</code>. 
276  * </li>
277  * </ul>
278  * <p ><b>Note:</b>  "validate-if-schema" and "validate" are mutually 
279  * exclusive, setting one of them to <code>true</code> will set the other 
280  * one to <code>false</code>. Applications should also consider setting the 
281  * parameter "well-formed" to <code>true</code>, which is the default for 
282  * that option, when validating the document. </dd>
283  * <dt><code>false</code></dt>
284  * <dd>[<em>required</em>] (<em>default</em>) Do not accomplish schema processing, including the internal subset 
285  * processing. Note that validation might still happen if "
286  * "validate-if-schema" is <code>true</code>. </dd>
287  * </dl></dd>
288  * <dt>
289  * <code>"validate-if-schema"</code></dt>
290  * <dd>
291  * <dl>
292  * <dt><code>true</code></dt>
293  * <dd>[<em>optional</em>]Enable validation only if a declaration for the document element can be 
294  * found in a schema (independently of where it is found, i.e. XML schema, 
295  * DTD, or any other type or representation of schema). If validation is 
296  * enabled, this parameter has the same behavior as the parameter "validate" 
297  * set to <code>true</code>. 
298  * <p ><b>Note:</b>  "validate-if-schema" and "validate" are mutually 
299  * exclusive, setting one of them to <code>true</code> will set the other 
300  * one to <code>false</code>. </dd>
301  * <dt><code>false</code></dt>
302  * <dd>[<em>required</em>] (<em>default</em>) No schema processing should be performed if the document has a schema, 
303  * including internal subset processing. Note that validation must still 
304  * happen if "validate" is <code>true</code>. </dd>
305  * </dl></dd>
306  * <dt><code>"well-formed"</code></dt>
307  * <dd>
308  * <dl>
309  * <dt>
310  * <code>true</code></dt>
311  * <dd>[<em>required</em>] (<em>default</em>) Check if all nodes are XML well formed according to the XML version in 
312  * use in <code>Document.xmlVersion</code>: 
313  * <ul>
314  * <li> check if the attribute 
315  * <code>Node.nodeName</code> contains invalid characters according to its 
316  * node type and generate a <code>DOMError</code> of type 
317  * <code>"wf-invalid-character-in-node-name"</code>, with a 
318  * <code>DOMError.SEVERITY_ERROR</code> severity, if necessary; 
319  * </li>
320  * <li> check if 
321  * the text content inside <code>Attr</code>, <code>Element</code>, 
322  * <code>Comment</code>, <code>Text</code>, <code>CDATASection</code> nodes 
323  * for invalid characters and generate a <code>DOMError</code> of type 
324  * <code>"wf-invalid-character"</code>, with a 
325  * <code>DOMError.SEVERITY_ERROR</code> severity, if necessary; 
326  * </li>
327  * <li> check if 
328  * the data inside <code>ProcessingInstruction</code> nodes for invalid 
329  * characters and generate a <code>DOMError</code> of type 
330  * <code>"wf-invalid-character"</code>, with a 
331  * <code>DOMError.SEVERITY_ERROR</code> severity, if necessary; 
332  * </li>
333  * </ul></dd>
334  * <dt>
335  * <code>false</code></dt>
336  * <dd>[<em>optional</em>] Do not check for XML well-formedness. </dd>
337  * </dl></dd>
338  * <dt>
339  * <code>"element-content-whitespace"</code></dt>
340  * <dd>
341  * <dl>
342  * <dt><code>true</code></dt>
343  * <dd>[<em>required</em>] (<em>default</em>)Keep all whitespaces in the document.</dd>
344  * <dt><code>false</code></dt>
345  * <dd>[<em>optional</em>] Discard all <code>Text</code> nodes that contain whitespaces in element 
346  * content, as described in <a href='http://www.w3.org/TR/2001/REC-xml-infoset-20011024#infoitem.character'>
347  * [element content whitespace]</a>. The implementation is expected to use the attribute 
348  * <code>Text.isElementContentWhitespace</code> to determine if a 
349  * <code>Text</code> node should be discarded or not.</dd>
350  * </dl></dd>
351  * </dl>
352  * <p> The resolution of the system identifiers associated with entities is 
353  * done using <code>Document.documentURI</code>. However, when the feature 
354  * "LS" defined in [<a href='http://www.w3.org/TR/2003/CR-DOM-Level-3-LS-20031107'>DOM Level 3 Load and Save</a>]
355  *  is supported by the DOM implementation, the parameter 
356  * "resource-resolver" can also be used on <code>DOMConfiguration</code> 
357  * objects attached to <code>Document</code> nodes. If this parameter is 
358  * set, <code>Document.normalizeDocument()</code> will invoke the resource 
359  * resolver instead of using <code>Document.documentURI</code>. 
360  * <p>See also the <a href='http://www.w3.org/TR/2003/CR-DOM-Level-3-Core-20031107'>Document Object Model (DOM) Level 3 Core Specification</a>.
361  * @since DOM Level 3
362  */
363 public interface DOMConfiguration {
364     /**
365      * Set the value of a parameter.
366      * @param name The name of the parameter to set.
367      * @param value  The new value or <code>null</code> if the user wishes to 
368      *   unset the parameter. While the type of the value parameter is 
369      *   defined as <code>DOMUserData</code>, the object type must match the 
370      *   type defined by the definition of the parameter. For example, if 
371      *   the parameter is "error-handler", the value must be of type 
372      *   <code>DOMErrorHandler</code>. 
373      * @exception DOMException
374      *    NOT_FOUND_ERR: Raised when the parameter name is not recognized. 
375      *   <br> NOT_SUPPORTED_ERR: Raised when the parameter name is recognized 
376      *   but the requested value cannot be set. 
377      *   <br> TYPE_MISMATCH_ERR: Raised if the value type for this parameter 
378      *   name is incompatible with the expected value type. 
379      */
380     public void setParameter(String name, 
381                              Object value)
382                              throws DOMException;
383 
384     /**
385      *  Return the value of a parameter if known. 
386      * @param name  The name of the parameter. 
387      * @return  The current object associated with the specified parameter or 
388      *   <code>null</code> if no object has been associated or if the 
389      *   parameter is not supported. 
390      * @exception DOMException
391      *    NOT_FOUND_ERR: Raised when the parameter name is not recognized. 
392      */
393     public Object getParameter(String name)
394                                throws DOMException;
395 
396     /**
397      * Check if setting a parameter to a specific value is supported.
398      * @param name The name of the parameter to check.
399      * @param value  An object. if <code>null</code>, the returned value is 
400      *   <code>true</code>. 
401      * @return  <code>true</code> if the parameter could be successfully set 
402      *   to the specified value, or <code>false</code> if the parameter is 
403      *   not recognized or the requested value is not supported. This does 
404      *   not change the current value of the parameter itself. 
405      */
406     public boolean canSetParameter(String name, 
407                                    Object value);
408 
409     /**
410      *  The list of the parameters supported by this 
411      * <code>DOMConfiguration</code> object and for which at least one value 
412      * can be set by the application. Note that this list can also contain 
413      * parameter names defined outside this specification. 
414      */
415     public DOMStringList getParameterNames();
416 
417 }