source: NonGTP/Xerces/xercesc/dom/DOMConfiguration.hpp @ 188

Revision 188, 23.4 KB checked in by mattausch, 19 years ago (diff)

added xercesc to support

Line 
1/*
2 * The Apache Software License, Version 1.1
3 *
4 * Copyright (c) 2003 The Apache Software Foundation.  All rights
5 * reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * 1. Redistributions of source code must retain the above copyright
12 *    notice, this list of conditions and the following disclaimer.
13 *
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in
16 *    the documentation and/or other materials provided with the
17 *    distribution.
18 *
19 * 3. The end-user documentation included with the redistribution,
20 *    if any, must include the following acknowledgment:
21 *       "This product includes software developed by the
22 *        Apache Software Foundation (http://www.apache.org/)."
23 *    Alternately, this acknowledgment may appear in the software itself,
24 *    if and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Xerces" and "Apache Software Foundation" must
27 *    not be used to endorse or promote products derived from this
28 *    software without prior written permission. For written
29 *    permission, please contact apache\@apache.org.
30 *
31 * 5. Products derived from this software may not be called "Apache",
32 *    nor may "Apache" appear in their name, without prior written
33 *    permission of the Apache Software Foundation.
34 *
35 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
36 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
37 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
38 * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
39 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
42 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
44 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
45 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
46 * SUCH DAMAGE.
47 * ====================================================================
48 *
49 * This software consists of voluntary contributions made by many
50 * individuals on behalf of the Apache Software Foundation, and was
51 * originally based on software copyright (c) 2001, International
52 * Business Machines, Inc., http://www.ibm.com .  For more information
53 * on the Apache Software Foundation, please see
54 * <http://www.apache.org/>.
55 */
56
57#if !defined(DOMCONFIGURATION_HPP)
58#define DOMCONFIGURATION_HPP
59
60//------------------------------------------------------------------------------------
61//  Includes
62//------------------------------------------------------------------------------------
63
64#include <xercesc/util/XMLString.hpp>
65
66XERCES_CPP_NAMESPACE_BEGIN
67
68/**
69 *   The DOMConfiguration interface represents the configuration of
70 *   a document  and  maintains  a  table of recognized parameters.
71 *   using  the   configuration,   it   is   possible   to   change
72 *   Document.normalizeDocument  behavior,  such  as replacing
73 *   CDATASection   nodes   with   Text  nodes  or
74 *   specifying  the  type  of the schema that must be used when the
75 *   validation of the Document is requested. DOMConfiguration
76 *   objects  are  also used in [DOM Level 3 Load and Save] in
77 *   the DOMBuilder and DOMWriter interfaces.
78 *
79 *   The  DOMConfiguration  distinguish  two  types  of  parameters:
80 *   boolean     (boolean    parameters)    and    DOMUserData
81 *   (parameters). The names used by the DOMConfiguration object are
82 *   defined  throughout  the  DOM Level 3 specifications. Names are
83 *   case-insensitives.   To   avoid   possible   conflicts,   as  a
84 *   convention,   names   referring   to   boolean  parameters  and
85 *   parameters defined outside the DOM specification should be made
86 *   unique.  Names  are  recommended  to  follow the XML name
87 *   production   rule   but   it   is   not  enforced  by  the  DOM
88 *   implementation.  DOM  Level 3 Core Implementations are required
89 *   to  recognize  all boolean parameters and parameters defined in
90 *   this  specification.  Each boolean parameter state or parameter
91 *   value may then be supported or not by the implementation. Refer
92 *   to  their  definition  to  know  if  a state or a value must be
93 *   supported or not.
94 *
95 *   Note: Parameters are similar to features and properties used in
96 *   SAX2 [SAX].
97 *
98 * Issue DOMConfiguration-1:
99 *         Can we rename boolean parameters to "flags"?
100 *
101 * Issue DOMConfiguration-2:
102 *         Are  boolean  parameters  and  parameters within the same
103 *         scope for uniqueness? Which exception should be raised by
104 *         setBooleanParameter("error-handler", true)?
105 *
106 *   The following list of parameters defined in the DOM:
107 *
108 * "error-handler"
109 *         [required]
110 *         A   DOMErrorHandler   object.   If   an   error  is
111 *         encountered in the document, the implementation will call
112 *         back  the  DOMErrorHandler  registered  using  this
113 *         parameter.
114 *         When  called, DOMError.relatedData will contain the
115 *         closest   node   to  where  the  error  occured.  If  the
116 *         implementation  is unable to determine the node where the
117 *         error occurs, DOMError.relatedData will contain the
118 *         Document  node.  Mutations  to  the  document  from
119 *         within  an  error  handler  will result in implementation
120 *         dependent behaviour.
121 *
122 *       Issue DOMConfiguration-4:
123 *               Should   we   say  non  "readonly"  operations  are
124 *               implementation dependent instead?
125 *               Resolution:  Removed:  "or re-invoking a validation
126 *               operation".
127 *
128 * "schema-type"
129 *         [optional]
130 *         A  DOMString  object containing an absolute URI and
131 *         representing  the  type  of  the  schema language used to
132 *         validate   a  document  against.  Note  that  no  lexical
133 *         checking is done on the absolute URI.
134 *         If  this  parameter  is  not  set, a default value may be
135 *         provided  by  the  implementation,  based  on  the schema
136 *         languages  supported  and  on the schema language used at
137 *         load time.
138 *
139 *         Note:   For   XML   Schema  [XML  Schema  Part  1],
140 *         applications must use the value
141 *         "http://www.w3.org/2001/XMLSchema".     For    XML    DTD
142 *         [XML   1.0],   applications   must  use  the  value
143 *         "http://www.w3.org/TR/REC-xml".  Other  schema  languages
144 *         are  outside  the  scope  of the W3C and therefore should
145 *         recommend an absolute URI in order to use this method.
146 *
147 * "schema-location"
148 *         [optional]
149 *         A  DOMString  object  containing  a  list  of URIs,
150 *         separated   by  white  spaces  (characters  matching  the
151 *         nonterminal  production  S  defined  in section 2.3
152 *         [XML  1.0]),  that  represents  the schemas against
153 *         which  validation  should  occur.  The  types  of schemas
154 *         referenced  in  this  list  must match the type specified
155 *         with   schema-type,   otherwise   the   behaviour  of  an
156 *         implementation  is  undefined.  If the schema type is XML
157 *         Schema  [XML  Schema  Part  1], only one of the XML
158 *         Schemas in the list can be with no namespace.
159 *         If  validation  occurs  against a namespace aware schema,
160 *         i.e.  XML  Schema,  and  the  targetNamespace of a schema
161 *         (specified    using    this    property)    matches   the
162 *         targetNamespace  of  a  schema  occurring in the instance
163 *         document,  i.e  in  schemaLocation  attribute, the schema
164 *         specified  by  the  user using this property will be used
165 *         (i.e.,  in XML Schema the schemaLocation attribute in the
166 *         instance  document  or  on  the  import  element  will be
167 *         effectively ignored).
168 *
169 *         Note:  It is illegal to set the schema-location parameter
170 *         if  the  schema-type  parameter  value  is not set. It is
171 *         strongly  recommended that DOMInputSource.baseURI will be
172 *         set,  so  that an implementation can successfully resolve
173 *         any external entities referenced.
174 *
175 *   The  following list of boolean parameters (features) defined in
176 *   the DOM:
177 *
178 * "canonical-form"
179 *
180 *       true
181 *               [optional]
182 *               Canonicalize  the  document  according to the rules
183 *               specified  in [Canonical XML]. Note that this
184 *               is  limited  to what can be represented in the DOM.
185 *               In particular, there is no way to specify the order
186 *               of the attributes in the DOM.
187 *
188 *             Issue normalizationFeature-14:
189 *                     What  happen  to  other  features?  are  they
190 *                     ignored? if yes, how do you know if a feature
191 *                     is ignored?
192 *
193 *       false
194 *               [required] (default)
195 *               Do not canonicalize the document.
196 *
197 * "cdata-sections"
198 *
199 *       true
200 *               [required] (default)
201 *               Keep CDATASection nodes in the document.
202 *
203 *             Issue normalizationFeature-11:
204 *                     Name  does not work really well in this case.
205 *                     ALH     suggests     renaming     this     to
206 *                     "cdata-sections".  It works for both load and
207 *                     save.
208 *                     Resolution:  Renamed as suggested. (Telcon 27
209 *                     Jan 2002).
210 *
211 *       false
212 *               [required]
213 *               Transform  CDATASection nodes in the document
214 *               into  Text  nodes. The new Text node is
215 *               then combined with any adjacent Text node.
216 *
217 * "comments"
218 *
219 *       true
220 *               [required] (default)
221 *               Keep Comment nodes in the document.
222 *
223 *       false
224 *               [required]
225 *               Discard Comment nodes in the Document.
226 *
227 * "datatype-normalization"
228 *
229 *       true
230 *               [required]
231 *               Exposed normalized values in the tree.
232 *
233 *             Issue normalizationFeature-8:
234 *                     We should define "datatype normalization".
235 *                     Resolution:  DTD  normalization  always apply
236 *                     because  it's  part  of  XML 1.0. Clarify the
237 *                     spec. (Telcon 27 Jan 2002).
238 *
239 *       false
240 *               [required] (default)
241 *               Do not perform normalization on the tree.
242 *
243 * "discard-default-content"
244 *
245 *       true
246 *               [required] (default)
247 *               Use   whatever   information   available   to   the
248 *               implementation (i.e. XML schema, DTD, the specified
249 *               flag on Attr nodes, and so on) to decide what
250 *               attributes  and content should be discarded or not.
251 *               Note that the specified flag on Attr nodes in
252 *               itself  is not always reliable, it is only reliable
253 *               when  it  is set to false since the only case where
254 *               it  can  be  set  to  false is if the attribute was
255 *               created  by the implementation. The default content
256 *               won't be removed if an implementation does not have
257 *               any information available.
258 *
259 *             Issue normalizationFeature-2:
260 *                     How  does  exactly  work?  What's the comment
261 *                     about level 1 implementations?
262 *                     Resolution:  Remove  "Level 1" (Telcon 16 Jan
263 *                     2002).
264 *
265 *       false
266 *               [required]
267 *               Keep all attributes and all content.
268 *
269 * "entities"
270 *
271 *       true
272 *               [required]
273 *               Keep  EntityReference  and Entity nodes
274 *               in the document.
275 *
276 *             Issue normalizationFeature-9:
277 *                     How does that interact with
278 *                     expand-entity-references?     ALH    suggests
279 *                     consolidating  the  two  to  a single feature
280 *                     called  "entity-references" that is used both
281 *                     for load and save.
282 *                     Resolution:  Consolidate both features into a
283 *                     single  feature called 'entities'. (Telcon 27
284 *                     Jan 2002).
285 *
286 *       false
287 *               [required] (default)
288 *               Remove  all  EntityReference and Entity
289 *               nodes   from   the  document,  putting  the  entity
290 *               expansions  directly  in  their  place.  Text
291 *               nodes     are     into    "normal"    form.    Only
292 *               EntityReference nodes to non-defined entities
293 *               are kept in the document.
294 *
295 * "infoset"
296 *
297 *       true
298 *               [required]
299 *               Only  keep  in the document the information defined
300 *               in  the  XML Information Set [XML Information
301 *               set].
302 *               This   forces  the  following  features  to  false:
303 *               namespace-declarations,         validate-if-schema,
304 *               entities, datatype-normalization, cdata-sections.
305 *               This   forces   the  following  features  to  true:
306 *               whitespace-in-element-content,            comments,
307 *               namespaces.
308 *               Other  features  are  not  changed unless explicity
309 *               specified in the description of the features.
310 *               Note  that  querying  this  feature with getFeature
311 *               returns   true  only  if  the  individual  features
312 *               specified above are appropriately set.
313 *
314 *             Issue normalizationFeature-12:
315 *                     Name  doesn't  work  well  here. ALH suggests
316 *                     renaming    this   to   limit-to-infoset   or
317 *                     match-infoset, something like that.
318 *                     Resolution:  Renamed 'infoset' (Telcon 27 Jan
319 *                     2002).
320 *
321 *       false
322 *               Setting infoset to false has no effect.
323 *
324 *             Issue normalizationFeature-13:
325 *                     Shouldn't  we  change  this  to  setting  the
326 *                     relevant options back to their default value?
327 *                     Resolution:   No,   this   is   more  like  a
328 *                     convenience  function, it's better to keep it
329 *                     simple. (F2F 28 Feb 2002).
330 *
331 * "namespaces"
332 *
333 *       true
334 *               [required] (default)
335 *               Perform  the  namespace  processing  as  defined in
336 *               [XML Namespaces].
337 *
338 *       false
339 *               [optional]
340 *               Do not perform the namespace processing.
341 *
342 * "namespace-declarations"
343 *
344 *       true
345 *               [required] (default)
346 *               Include namespace declaration attributes, specified
347 *               or  defaulted  from  the  schema or the DTD, in the
348 *               document.  See  also  the  section  Declaring
349 *               Namespaces in [XML Namespaces].
350 *
351 *       false
352 *               [required]
353 *               Discard  all  namespace declaration attributes. The
354 *               Namespace   prefixes  are  retained  even  if  this
355 *               feature is set to false.
356 *
357 * "normalize-characters"
358 *
359 *       true
360 *               [optional]
361 *               Perform   the   W3C   Text   Normalization  of  the
362 *               characters [CharModel] in the document.
363 *
364 *       false
365 *               [required] (default)
366 *               Do not perform character normalization.
367 *
368 * "split-cdata-sections"
369 *
370 *       true
371 *               [required] (default)
372 *               Split  CDATA  sections containing the CDATA section
373 *               termination  marker  ']]>'. When a CDATA section is
374 *               split a warning is issued.
375 *
376 *       false
377 *               [required]
378 *               Signal an error if a CDATASection contains an
379 *               unrepresentable character.
380 *
381 * "validate"
382 *
383 *       true
384 *               [optional]
385 *               Require  the  validation against a schema (i.e. XML
386 *               schema,  DTD,  any  other type or representation of
387 *               schema)  of  the document as it is being normalized
388 *               as defined by [XML 1.0]. If validation errors
389 *               are  found,  or  no  schema  was  found,  the error
390 *               handler  is  notified.  Note  also  that normalized
391 *               values  will  not  be exposed to the schema in used
392 *               unless the feature datatype-normalization is true.
393 *
394 *               Note:  validate-if-schema and validate are mutually
395 *               exclusive, setting one of them to true will set the
396 *               other one to false.
397 *
398 *       false
399 *               [required] (default)
400 *               Only  XML  1.0  non-validating  processing  must be
401 *               done.  Note  that  validation might still happen if
402 *               validate-if-schema is true.
403 *
404 * "validate-if-schema"
405 *
406 *       true
407 *               [optional]
408 *               Enable  validation  only  if  a declaration for the
409 *               document  element  can  be  found (independently of
410 *               where  it  is  found,  i.e. XML schema, DTD, or any
411 *               other   type   or  representation  of  schema).  If
412 *               validation  errors  are found, the error handler is
413 *               notified. Note also that normalized values will not
414 *               be exposed to the schema in used unless the feature
415 *               datatype-normalization is true.
416 *
417 *               Note:  validate-if-schema and validate are mutually
418 *               exclusive, setting one of them to true will set the
419 *               other one to false.
420 *
421 *       false
422 *               [required] (default)
423 *               No  validation  should be performed if the document
424 *               has  a  schema.  Note  that  validation  must still
425 *               happen if validate is true.
426 *
427 * "whitespace-in-element-content"
428 *
429 *       true
430 *               [required] (default)
431 *               Keep all white spaces in the document.
432 *
433 *             Issue normalizationFeature-15:
434 *                     How   does   this   feature   interact   with
435 *                     "validate" and
436 *                     Text.isWhitespaceInElementContent.
437 *                     Resolution:  issue  no  longer  relevant (f2f
438 *                     october 2002).
439 *
440 *       false
441 *               [optional]
442 *               Discard   white  space  in  element  content  while
443 *               normalizing.  The implementation is expected to use
444 *               the isWhitespaceInElementContent flag on Text
445 *               nodes to determine if a text node should be written
446 *               out or not.
447 *
448 *   The  resolutions  of  entities  is done using Document.baseURI.
449 *   However,  when  the  features "LS-Load" or "LS-Save" defined in
450 *   [DOM  Level  3  Load  and  Save] are supported by the DOM
451 *   implementation,  the  parameter  "entity-resolver"  can also be
452 *   used  on  DOMConfiguration  objects  attached to Document
453 *   nodes. If this parameter is set,
454 *   Document.normalizeDocument   will   invoke   the   entity
455 *   resolver instead of using Document.baseURI.
456 */
457class CDOM_EXPORT DOMConfiguration
458{
459protected:
460    //-----------------------------------------------------------------------------------
461    //  Constructor
462    //-----------------------------------------------------------------------------------
463    /** @name Hidden constructors */
464    //@{
465    DOMConfiguration() {};
466    //@}
467
468private:
469    // -----------------------------------------------------------------------
470    // Unimplemented constructors and operators
471    // -----------------------------------------------------------------------
472    /** @name Unimplemented constructors and operators */
473    //@{
474    DOMConfiguration(const DOMConfiguration &);
475    DOMConfiguration & operator = (const DOMConfiguration &);
476    //@}
477
478public:
479
480    // -----------------------------------------------------------------------
481    //  Setter methods
482    // -----------------------------------------------------------------------
483   
484    /** Set the value of a parameter.
485     * @param name The name of the parameter to set.
486     * @param value The new value or null if the user wishes to unset the
487     * parameter. While the type of the value parameter is defined as
488     * <code>DOMUserData</code>, the object type must match the type defined
489     * by the definition of the parameter. For example, if the parameter is
490     * "error-handler", the value must be of type <code>DOMErrorHandler</code>
491     * @exception DOMException (NOT_SUPPORTED_ERR) Raised when the
492     * parameter name is recognized but the requested value cannot be set.
493     * @exception DOMException (NOT_FOUND_ERR) Raised when the
494     * parameter name is not recognized.
495     * @since DOM level 3
496     **/
497    virtual void setParameter(const XMLCh* name, const void* value) = 0;
498
499    // -----------------------------------------------------------------------
500    //  Getter methods
501    // -----------------------------------------------------------------------
502    /** Return the value of a parameter if known.
503     * @param name The name of the parameter.
504     * @return The current object associated with the specified parameter or
505     * null if no object has been associated or if the parameter is not
506     * supported.
507     * @exception DOMException (NOT_FOUND_ERR) Raised when the i
508     * boolean parameter
509     * name is not recognized.
510     * @since DOM level 3
511     **/   
512    virtual const void* getParameter(const XMLCh* name) const = 0;
513
514                                       
515    // -----------------------------------------------------------------------
516    //  Query methods
517    // -----------------------------------------------------------------------
518
519    /** Check if setting a parameter to a specific value is supported.
520     * @param name The name of the parameter to check.
521     * @param value An object. if null, the returned value is true.
522     * @return true if the parameter could be successfully set to the specified
523     * value, or false if the parameter is not recognized or the requested value
524     * is not supported. This does not change the current value of the parameter
525     * itself.
526     * @since DOM level 3
527     **/
528    virtual bool canSetParameter(const XMLCh* name, const void* value) const = 0;
529
530    // -----------------------------------------------------------------------
531    //  All constructors are hidden, just the destructor is available
532    // -----------------------------------------------------------------------
533    /** @name Destructor */
534    //@{
535    /**
536     * Destructor
537     *
538     */
539    virtual ~DOMConfiguration() {};
540    //@}
541};
542       
543XERCES_CPP_NAMESPACE_END
544
545#endif
546
547/**
548 * End of file DOMConfiguration.hpp
549 */
Note: See TracBrowser for help on using the repository browser.