source: NonGTP/Xerces/xerces-c_2_8_0/include/xercesc/dom/DOMNode.hpp @ 2674

Revision 2674, 39.8 KB checked in by mattausch, 16 years ago (diff)
Line 
1#ifndef DOMNode_HEADER_GUARD_
2#define DOMNode_HEADER_GUARD_
3
4/*
5 * Licensed to the Apache Software Foundation (ASF) under one or more
6 * contributor license agreements.  See the NOTICE file distributed with
7 * this work for additional information regarding copyright ownership.
8 * The ASF licenses this file to You under the Apache License, Version 2.0
9 * (the "License"); you may not use this file except in compliance with
10 * the License.  You may obtain a copy of the License at
11 *
12 *      http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20
21/*
22 * $Id: DOMNode.hpp 568078 2007-08-21 11:43:25Z amassari $
23 */
24
25#include <xercesc/util/XercesDefs.hpp>
26
27XERCES_CPP_NAMESPACE_BEGIN
28
29
30class DOMDocument;
31class DOMNamedNodeMap;
32class DOMNodeList;
33class DOMUserDataHandler;
34
35/**
36 * The <code>DOMNode</code> interface is the primary datatype for the entire
37 * Document Object Model. It represents a single node in the document tree.
38 * While all objects implementing the <code>DOMNode</code> interface expose
39 * methods for dealing with children, not all objects implementing the
40 * <code>DOMNode</code> interface may have children. For example,
41 * <code>DOMText</code> nodes may not have children, and adding children to
42 * such nodes results in a <code>DOMException</code> being raised.
43 * <p>The attributes <code>nodeName</code>, <code>nodeValue</code> and
44 * <code>attributes</code> are included as a mechanism to get at node
45 * information without casting down to the specific derived interface. In
46 * cases where there is no obvious mapping of these attributes for a
47 * specific <code>nodeType</code> (e.g., <code>nodeValue</code> for an
48 * <code>DOMElement</code> or <code>attributes</code> for a <code>DOMComment</code>
49 * ), this returns <code>null</code>. Note that the specialized interfaces
50 * may contain additional and more convenient mechanisms to get and set the
51 * relevant information.
52 * <p>The values of <code>nodeName</code>,
53 * <code>nodeValue</code>, and <code>attributes</code> vary according to the
54 * node type as follows:
55 * <table border='1'>
56 * <tr>
57 * <td>Interface</td>
58 * <td>nodeName</td>
59 * <td>nodeValue</td>
60 * <td>attributes</td>
61 * </tr>
62 * <tr>
63 * <td valign='top' rowspan='1' colspan='1'>DOMAttr</td>
64 * <td valign='top' rowspan='1' colspan='1'>name of attribute</td>
65 * <td valign='top' rowspan='1' colspan='1'>value of attribute</td>
66 * <td valign='top' rowspan='1' colspan='1'>null</td>
67 * </tr>
68 * <tr>
69 * <td valign='top' rowspan='1' colspan='1'>DOMCDATASection</td>
70 * <td valign='top' rowspan='1' colspan='1'>&quot;#cdata-section&quot;</td>
71 * <td valign='top' rowspan='1' colspan='1'>content of the CDATA Section</td>
72 * <td valign='top' rowspan='1' colspan='1'>null</td>
73 * </tr>
74 * <tr>
75 * <td valign='top' rowspan='1' colspan='1'>DOMComment</td>
76 * <td valign='top' rowspan='1' colspan='1'>&quot;#comment&quot;</td>
77 * <td valign='top' rowspan='1' colspan='1'>content of the comment</td>
78 * <td valign='top' rowspan='1' colspan='1'>null</td>
79 * </tr>
80 * <tr>
81 * <td valign='top' rowspan='1' colspan='1'>DOMDocument</td>
82 * <td valign='top' rowspan='1' colspan='1'>&quot;#document&quot;</td>
83 * <td valign='top' rowspan='1' colspan='1'>null</td>
84 * <td valign='top' rowspan='1' colspan='1'>null</td>
85 * </tr>
86 * <tr>
87 * <td valign='top' rowspan='1' colspan='1'>DOMDocumentFragment</td>
88 * <td valign='top' rowspan='1' colspan='1'>&quot;#document-fragment&quot;</td>
89 * <td valign='top' rowspan='1' colspan='1'>null</td>
90 * <td valign='top' rowspan='1' colspan='1'>null</td>
91 * </tr>
92 * <tr>
93 * <td valign='top' rowspan='1' colspan='1'>DOMDocumentType</td>
94 * <td valign='top' rowspan='1' colspan='1'>document type name</td>
95 * <td valign='top' rowspan='1' colspan='1'>null</td>
96 * <td valign='top' rowspan='1' colspan='1'>null</td>
97 * </tr>
98 * <tr>
99 * <td valign='top' rowspan='1' colspan='1'>DOMElement</td>
100 * <td valign='top' rowspan='1' colspan='1'>tag name</td>
101 * <td valign='top' rowspan='1' colspan='1'>null</td>
102 * <td valign='top' rowspan='1' colspan='1'>NamedNodeMap</td>
103 * </tr>
104 * <tr>
105 * <td valign='top' rowspan='1' colspan='1'>DOMEntity</td>
106 * <td valign='top' rowspan='1' colspan='1'>entity name</td>
107 * <td valign='top' rowspan='1' colspan='1'>null</td>
108 * <td valign='top' rowspan='1' colspan='1'>null</td>
109 * </tr>
110 * <tr>
111 * <td valign='top' rowspan='1' colspan='1'>DOMEntityReference</td>
112 * <td valign='top' rowspan='1' colspan='1'>name of entity referenced</td>
113 * <td valign='top' rowspan='1' colspan='1'>null</td>
114 * <td valign='top' rowspan='1' colspan='1'>null</td>
115 * </tr>
116 * <tr>
117 * <td valign='top' rowspan='1' colspan='1'>DOMNotation</td>
118 * <td valign='top' rowspan='1' colspan='1'>notation name</td>
119 * <td valign='top' rowspan='1' colspan='1'>null</td>
120 * <td valign='top' rowspan='1' colspan='1'>null</td>
121 * </tr>
122 * <tr>
123 * <td valign='top' rowspan='1' colspan='1'>DOMProcessingInstruction</td>
124 * <td valign='top' rowspan='1' colspan='1'>target</td>
125 * <td valign='top' rowspan='1' colspan='1'>entire content excluding the target</td>
126 * <td valign='top' rowspan='1' colspan='1'>null</td>
127 * </tr>
128 * <tr>
129 * <td valign='top' rowspan='1' colspan='1'>DOMText</td>
130 * <td valign='top' rowspan='1' colspan='1'>&quot;#text&quot;</td>
131 * <td valign='top' rowspan='1' colspan='1'>content of the text node</td>
132 * <td valign='top' rowspan='1' colspan='1'>null</td>
133 * </tr>
134 * </table>
135 * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>.
136 *
137 * @since DOM Level 1
138 */
139class  CDOM_EXPORT DOMNode {
140protected:
141    // -----------------------------------------------------------------------
142    //  Hidden constructors
143    // -----------------------------------------------------------------------
144    /** @name Hidden constructors */
145    //@{   
146    DOMNode() {}
147    DOMNode(const DOMNode &) {}
148    //@}
149
150private:   
151    // -----------------------------------------------------------------------
152    // Unimplemented constructors and operators
153    // -----------------------------------------------------------------------
154    /** @name Unimplemented operators */
155    //@{
156    DOMNode & operator = (const DOMNode &);
157    //@}
158
159public:
160    // -----------------------------------------------------------------------
161    //  All constructors are hidden, just the destructor is available
162    // -----------------------------------------------------------------------
163    /** @name Destructor */
164    //@{
165    /**
166     * Destructor
167     *
168     */
169    virtual ~DOMNode() {};
170    //@}
171
172    // -----------------------------------------------------------------------
173    //  Class Types
174    // -----------------------------------------------------------------------
175    /** @name Public Contants */
176    //@{
177    /**
178     * NodeType
179     *
180     * @since DOM Level 1
181     */
182    enum NodeType {
183        ELEMENT_NODE                = 1,
184        ATTRIBUTE_NODE              = 2,
185        TEXT_NODE                   = 3,
186        CDATA_SECTION_NODE          = 4,
187        ENTITY_REFERENCE_NODE       = 5,
188        ENTITY_NODE                 = 6,
189        PROCESSING_INSTRUCTION_NODE = 7,
190        COMMENT_NODE                = 8,
191        DOCUMENT_NODE               = 9,
192        DOCUMENT_TYPE_NODE          = 10,
193        DOCUMENT_FRAGMENT_NODE      = 11,
194        NOTATION_NODE               = 12
195    };
196
197    /**
198     * TreePosition:
199     *
200     * <p><b>"Experimental - subject to change"</b></p>
201     *
202     * <p><code>TREE_POSITION_PRECEDING:</code>
203     * The node precedes the reference node.</p>
204     * <p><code>TREE_POSITION_FOLLOWING:</code>
205     * The node follows the reference node.</p>
206     * <p><code>TREE_POSITION_ANCESTOR:</code>
207     * The node is an ancestor of the reference node.</p>
208     * <p><code>TREE_POSITION_DESCENDANT:</code>
209     * The node is a descendant of the reference node.</p>
210     * <p><code>TREE_POSITION_EQUIVALENT:</code>
211     * The two nodes have an equivalent position. This is the case of two
212     * attributes that have the same <code>ownerElement</code>, and two
213     * nodes that are the same.</p>
214     * <p><code>TREE_POSITION_SAME_NODE:</code>
215     * The two nodes are the same. Two nodes that are the same have an
216     * equivalent position, though the reverse may not be true.</p>
217     * <p><code>TREE_POSITION_DISCONNECTED:</code>
218     * The two nodes are disconnected, they do not have any common ancestor.
219     * This is the case of two nodes that are not in the same document.</p>
220     *
221     * @since DOM Level 3
222     */
223    enum DOMTreePosition {
224        TREE_POSITION_PRECEDING   = 0x01,
225        TREE_POSITION_FOLLOWING   = 0x02,
226        TREE_POSITION_ANCESTOR    = 0x04,
227        TREE_POSITION_DESCENDANT  = 0x08,
228        TREE_POSITION_EQUIVALENT  = 0x10,
229        TREE_POSITION_SAME_NODE   = 0x20,
230        TREE_POSITION_DISCONNECTED = 0x00
231    };
232    //@}
233
234    // -----------------------------------------------------------------------
235    //  Virtual DOMNode interface
236    // -----------------------------------------------------------------------
237    /** @name Functions introduced in DOM Level 1 */
238    //@{
239    // -----------------------------------------------------------------------
240    //  Getter methods
241    // -----------------------------------------------------------------------
242    /**
243     * The name of this node, depending on its type; see the table above.
244     * @since DOM Level 1
245     */
246    virtual const XMLCh *   getNodeName() const = 0;
247
248    /**
249     * Gets the value of this node, depending on its type.
250     *
251     * @exception DOMException
252     *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
253     * @since DOM Level 1
254     */
255    virtual const XMLCh *       getNodeValue() const = 0;
256
257    /**
258     * An enum value representing the type of the underlying object.
259     * @since DOM Level 1
260     */
261    virtual short           getNodeType() const = 0;
262
263    /**
264     * Gets the parent of this node.
265     *
266     * All nodes, except <code>DOMDocument</code>,
267     * <code>DOMDocumentFragment</code>, and <code>DOMAttr</code> may have a parent.
268     * However, if a node has just been created and not yet added to the tree,
269     * or if it has been removed from the tree, a <code>null</code> DOMNode
270     * is returned.
271     * @since DOM Level 1
272     */
273    virtual DOMNode        *getParentNode() const = 0;
274
275    /**
276     * Gets a <code>DOMNodeList</code> that contains all children of this node.
277     *
278     * If there
279     * are no children, this is a <code>DOMNodeList</code> containing no nodes.
280     * The content of the returned <code>DOMNodeList</code> is "live" in the sense
281     * that, for instance, changes to the children of the node object that
282     * it was created from are immediately reflected in the nodes returned by
283     * the <code>DOMNodeList</code> accessors; it is not a static snapshot of the
284     * content of the node. This is true for every <code>DOMNodeList</code>,
285     * including the ones returned by the <code>getElementsByTagName</code>
286     * method.
287     * @since DOM Level 1
288     */
289    virtual DOMNodeList    *getChildNodes() const = 0;
290    /**
291     * Gets the first child of this node.
292     *
293     * If there is no such node, this returns <code>null</code>.
294     * @since DOM Level 1
295     */
296    virtual DOMNode        *getFirstChild() const = 0;
297
298    /**
299     * Gets the last child of this node.
300     *
301     * If there is no such node, this returns <code>null</code>.
302     * @since DOM Level 1
303     */
304    virtual DOMNode        *getLastChild() const = 0;
305
306    /**
307     * Gets the node immediately preceding this node.
308     *
309     * If there is no such node, this returns <code>null</code>.
310     * @since DOM Level 1
311     */
312    virtual DOMNode        *getPreviousSibling() const = 0;
313
314    /**
315     * Gets the node immediately following this node.
316     *
317     * If there is no such node, this returns <code>null</code>.
318     * @since DOM Level 1
319     */
320    virtual DOMNode        *getNextSibling() const = 0;
321
322    /**
323     * Gets a <code>DOMNamedNodeMap</code> containing the attributes of this node (if it
324     * is an <code>DOMElement</code>) or <code>null</code> otherwise.
325     * @since DOM Level 1
326     */
327    virtual DOMNamedNodeMap  *getAttributes() const = 0;
328
329    /**
330     * Gets the <code>DOMDocument</code> object associated with this node.
331     *
332     * This is also
333     * the <code>DOMDocument</code> object used to create new nodes. When this
334     * node is a <code>DOMDocument</code> or a <code>DOMDocumentType</code>
335     * which is not used with any <code>DOMDocument</code> yet, this is
336     * <code>null</code>.
337     *
338     * @since DOM Level 1
339     */
340    virtual DOMDocument      *getOwnerDocument() const = 0;
341
342    // -----------------------------------------------------------------------
343    //  Node methods
344    // -----------------------------------------------------------------------
345    /**
346     * Returns a duplicate of this node.
347     *
348     * This function serves as a generic copy constructor for nodes.
349     *
350     * The duplicate node has no parent (
351     * <code>parentNode</code> returns <code>null</code>.).
352     * <br>Cloning an <code>DOMElement</code> copies all attributes and their
353     * values, including those generated by the  XML processor to represent
354     * defaulted attributes, but this method does not copy any text it contains
355     * unless it is a deep clone, since the text is contained in a child
356     * <code>DOMText</code> node. Cloning any other type of node simply returns a
357     * copy of this node.
358     * @param deep If <code>true</code>, recursively clone the subtree under the
359     *   specified node; if <code>false</code>, clone only the node itself (and
360     *   its attributes, if it is an <code>DOMElement</code>).
361     * @return The duplicate node.
362     * @since DOM Level 1
363     */
364    virtual DOMNode        * cloneNode(bool deep) const = 0;
365
366    /**
367     * Inserts the node <code>newChild</code> before the existing child node
368     * <code>refChild</code>.
369     *
370     * If <code>refChild</code> is <code>null</code>,
371     * insert <code>newChild</code> at the end of the list of children.
372     * <br>If <code>newChild</code> is a <code>DOMDocumentFragment</code> object,
373     * all of its children are inserted, in the same order, before
374     * <code>refChild</code>. If the <code>newChild</code> is already in the
375     * tree, it is first removed.  Note that a <code>DOMNode</code> that
376     * has never been assigned to refer to an actual node is == null.
377     * @param newChild The node to insert.
378     * @param refChild The reference node, i.e., the node before which the new
379     *   node must be inserted.
380     * @return The node being inserted.
381     * @exception DOMException
382     *   HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
383     *   allow children of the type of the <code>newChild</code> node, or if
384     *   the node to insert is one of this node's ancestors.
385     *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
386     *   from a different document than the one that created this node.
387     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being
388     *   inserted is readonly.
389     *   <br>NOT_FOUND_ERR: Raised if <code>refChild</code> is not a child of
390     *   this node.
391     * @since DOM Level 1
392     */
393    virtual DOMNode       *insertBefore(DOMNode *newChild,
394                                          DOMNode *refChild) = 0;
395
396
397    /**
398     * Replaces the child node <code>oldChild</code> with <code>newChild</code>
399     * in the list of children, and returns the <code>oldChild</code> node.
400     *
401     * If <CODE>newChild</CODE> is a <CODE>DOMDocumentFragment</CODE> object,
402     * <CODE>oldChild</CODE> is replaced by all of the <CODE>DOMDocumentFragment</CODE>
403     * children, which are inserted in the same order.
404     *
405     * If the <code>newChild</code> is already in the tree, it is first removed.
406     * @param newChild The new node to put in the child list.
407     * @param oldChild The node being replaced in the list.
408     * @return The node replaced.
409     * @exception DOMException
410     *   HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
411     *   allow children of the type of the <code>newChild</code> node, or it
412     *   the node to put in is one of this node's ancestors.
413     *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
414     *   from a different document than the one that created this node.
415     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the new node is readonly.
416     *   <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
417     *   this node.
418     * @since DOM Level 1
419     */
420    virtual DOMNode  *replaceChild(DOMNode *newChild,
421                                     DOMNode *oldChild) = 0;
422    /**
423     * Removes the child node indicated by <code>oldChild</code> from the list
424     * of children, and returns it.
425     *
426     * @param oldChild The node being removed.
427     * @return The node removed.
428     * @exception DOMException
429     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
430     *   <br>NOT_FOUND_ERR: Raised if <code>oldChild</code> is not a child of
431     *   this node.
432     * @since DOM Level 1
433     */
434    virtual DOMNode        *removeChild(DOMNode *oldChild) = 0;
435
436    /**
437     * Adds the node <code>newChild</code> to the end of the list of children of
438     * this node.
439     *
440     * If the <code>newChild</code> is already in the tree, it is
441     * first removed.
442     * @param newChild The node to add.If it is a  <code>DOMDocumentFragment</code>
443     *   object, the entire contents of the document fragment are moved into
444     *   the child list of this node
445     * @return The node added.
446     * @exception DOMException
447     *   HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
448     *   allow children of the type of the <code>newChild</code> node, or if
449     *   the node to append is one of this node's ancestors.
450     *   <br>WRONG_DOCUMENT_ERR: Raised if <code>newChild</code> was created
451     *   from a different document than the one that created this node.
452     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the node being
453     *   appended is readonly.
454     * @since DOM Level 1
455     */
456    virtual DOMNode        *appendChild(DOMNode *newChild) = 0;
457
458    // -----------------------------------------------------------------------
459    //  Query methods
460    // -----------------------------------------------------------------------
461    /**
462     *  This is a convenience method to allow easy determination of whether a
463     * node has any children.
464     *
465     * @return  <code>true</code> if the node has any children,
466     *   <code>false</code> if the node has no children.
467     * @since DOM Level 1
468     */
469    virtual bool             hasChildNodes() const = 0;
470
471    // -----------------------------------------------------------------------
472    //  Setter methods
473    // -----------------------------------------------------------------------
474    /**
475     * Sets the value of the node.
476     *
477     * Any node which can have a nodeValue will
478     * also accept requests to set it to a string. The exact response to
479     * this varies from node to node -- Attribute, for example, stores
480     * its values in its children and has to replace them with a new Text
481     * holding the replacement value.
482     *
483     * For most types of Node, value is null and attempting to set it
484     * will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
485     * also be thrown if the node is read-only.
486     * @see #getNodeValue
487     * @since DOM Level 1
488     */
489    virtual void              setNodeValue(const XMLCh  *nodeValue) = 0;
490    //@}
491
492    /** @name Functions introduced in DOM Level 2. */
493    //@{
494    /**
495     * Puts all <CODE>DOMText</CODE>
496     * nodes in the full depth of the sub-tree underneath this <CODE>DOMNode</CODE>,
497     * including attribute nodes, into a "normal" form where only markup (e.g.,
498     * tags, comments, processing instructions, CDATA sections, and entity
499     * references) separates <CODE>DOMText</CODE>
500     * nodes, i.e., there are neither adjacent <CODE>DOMText</CODE>
501     * nodes nor empty <CODE>DOMText</CODE>
502     * nodes. This can be used to ensure that the DOM view of a document is the
503     * same as if it were saved and re-loaded, and is useful when operations
504     * (such as XPointer lookups) that depend on a particular document tree
505     * structure are to be used.
506     * <P><B>Note:</B> In cases where the document contains <CODE>DOMCDATASections</CODE>,
507     * the normalize operation alone may not be sufficient, since XPointers do
508     * not differentiate between <CODE>DOMText</CODE>
509     * nodes and <CODE>DOMCDATASection</CODE>
510     * nodes.</P>
511     *
512     * @since DOM Level 2
513     */
514    virtual void              normalize() = 0;
515
516    /**
517     * Tests whether the DOM implementation implements a specific
518     * feature and that feature is supported by this node.
519     *
520     * @param feature The string of the feature to test. This is the same
521     * name as what can be passed to the method <code>hasFeature</code> on
522     * <code>DOMImplementation</code>.
523     * @param version This is the version number of the feature to test. In
524     * Level 2, version 1, this is the string "2.0". If the version is not
525     * specified, supporting any version of the feature will cause the
526     * method to return <code>true</code>.
527     * @return Returns <code>true</code> if the specified feature is supported
528     * on this node, <code>false</code> otherwise.
529     * @since DOM Level 2
530     */
531    virtual bool              isSupported(const XMLCh *feature,
532                                               const XMLCh *version) const = 0;
533
534    /**
535     * Get the <em>namespace URI</em> of
536     * this node, or <code>null</code> if it is unspecified.
537     * <p>
538     * This is not a computed value that is the result of a namespace lookup
539     * based on an examination of the namespace declarations in scope. It is
540     * merely the namespace URI given at creation time.
541     * <p>
542     * For nodes of any type other than <CODE>ELEMENT_NODE</CODE> and
543     * <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
544     * such as <CODE>createElement</CODE> from the <CODE>DOMDocument</CODE>
545     * interface, this is always <CODE>null</CODE>.
546     *
547     * @since DOM Level 2
548     */
549    virtual const XMLCh *         getNamespaceURI() const = 0;
550
551    /**
552     * Get the <em>namespace prefix</em>
553     * of this node, or <code>null</code> if it is unspecified.
554     *
555     * @since DOM Level 2
556     */
557    virtual const XMLCh *          getPrefix() const = 0;
558
559    /**
560     * Returns the local part of the <em>qualified name</em> of this node.
561     * <p>
562     * For nodes created with a DOM Level 1 method, such as
563     * <code>createElement</code> from the <code>DOMDocument</code> interface,
564     * it is null.
565     *
566     * @since DOM Level 2
567     */
568    virtual const XMLCh *          getLocalName() const = 0;
569
570    /**
571     * Set the <em>namespace prefix</em> of this node.
572     * <p>
573     * Note that setting this attribute, when permitted, changes
574     * the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
575     * name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
576     * attributes of the <CODE>DOMElement</CODE> and <CODE>DOMAttr</CODE>
577     * interfaces, when applicable.
578     * <p>
579     * Note also that changing the prefix of an
580     * attribute, that is known to have a default value, does not make a new
581     * attribute with the default value and the original prefix appear, since the
582     * <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
583     *
584     *
585     * @param prefix The prefix of this node.
586     * @exception DOMException
587     *   INVALID_CHARACTER_ERR: Raised if the specified prefix contains
588     *                          an illegal character.
589     * <br>
590     *   NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
591     * <br>
592     *   NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
593     *      malformed, if the <CODE>namespaceURI</CODE> of this node is
594     *      <CODE>null</CODE>, if the specified prefix is "xml" and the
595     *      <CODE>namespaceURI</CODE> of this node is different from
596     *      "http://www.w3.org/XML/1998/namespace", if this node is an attribute
597     *      and the specified prefix is "xmlns" and the
598     *      <CODE>namespaceURI</CODE> of this node is different from
599     *      "http://www.w3.org/2000/xmlns/", or if this node is an attribute and
600     *      the <CODE>qualifiedName</CODE> of this node is "xmlns".
601     * @since DOM Level 2
602     */
603    virtual void              setPrefix(const XMLCh * prefix) = 0;
604
605    /**
606     *  Returns whether this node (if it is an element) has any attributes.
607     * @return <code>true</code> if this node has any attributes,
608     *   <code>false</code> otherwise.
609     * @since DOM Level 2
610     */
611    virtual bool              hasAttributes() const = 0;
612    //@}
613
614    /** @name Functions introduced in DOM Level 3. */
615    //@{
616    /**
617     * Returns whether this node is the same node as the given one.
618     * <br>This method provides a way to determine whether two
619     * <code>DOMNode</code> references returned by the implementation reference
620     * the same object. When two <code>DOMNode</code> references are references
621     * to the same object, even if through a proxy, the references may be
622     * used completely interchangeably, such that all attributes have the
623     * same values and calling the same DOM method on either reference
624     * always has exactly the same effect.
625     *
626     * <p><b>"Experimental - subject to change"</b></p>
627     *
628     * @param other The node to test against.
629     * @return Returns <code>true</code> if the nodes are the same,
630     *   <code>false</code> otherwise.
631     * @since DOM Level 3
632     */
633    virtual bool              isSameNode(const DOMNode* other) const = 0;
634
635    /**
636     * Tests whether two nodes are equal.
637     * <br>This method tests for equality of nodes, not sameness (i.e.,
638     * whether the two nodes are pointers to the same object) which can be
639     * tested with <code>DOMNode::isSameNode</code>. All nodes that are the same
640     * will also be equal, though the reverse may not be true.
641     * <br>Two nodes are equal if and only if the following conditions are
642     * satisfied: The two nodes are of the same type.The following string
643     * attributes are equal: <code>nodeName</code>, <code>localName</code>,
644     * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code>
645     * , <code>baseURI</code>. This is: they are both <code>null</code>, or
646     * they have the same length and are character for character identical.
647     * The <code>attributes</code> <code>DOMNamedNodeMaps</code> are equal.
648     * This is: they are both <code>null</code>, or they have the same
649     * length and for each node that exists in one map there is a node that
650     * exists in the other map and is equal, although not necessarily at the
651     * same index.The <code>childNodes</code> <code>DOMNodeLists</code> are
652     * equal. This is: they are both <code>null</code>, or they have the
653     * same length and contain equal nodes at the same index. This is true
654     * for <code>DOMAttr</code> nodes as for any other type of node. Note that
655     * normalization can affect equality; to avoid this, nodes should be
656     * normalized before being compared.
657     * <br>For two <code>DOMDocumentType</code> nodes to be equal, the following
658     * conditions must also be satisfied: The following string attributes
659     * are equal: <code>publicId</code>, <code>systemId</code>,
660     * <code>internalSubset</code>.The <code>entities</code>
661     * <code>DOMNamedNodeMaps</code> are equal.The <code>notations</code>
662     * <code>DOMNamedNodeMaps</code> are equal.
663     * <br>On the other hand, the following do not affect equality: the
664     * <code>ownerDocument</code> attribute, the <code>specified</code>
665     * attribute for <code>DOMAttr</code> nodes, the
666     * <code>isWhitespaceInElementContent</code> attribute for
667     * <code>DOMText</code> nodes, as well as any user data or event listeners
668     * registered on the nodes.
669     *
670     * <p><b>"Experimental - subject to change"</b></p>
671     *
672     * @param arg The node to compare equality with.
673     * @return If the nodes, and possibly subtrees are equal,
674     *   <code>true</code> otherwise <code>false</code>.
675     * @since DOM Level 3
676     */
677    virtual bool              isEqualNode(const DOMNode* arg) const = 0;
678
679
680    /**
681     * Associate an object to a key on this node. The object can later be
682     * retrieved from this node by calling <code>getUserData</code> with the
683     * same key.
684     *
685     * Deletion of the user data remains the responsibility of the
686     * application program; it will not be automatically deleted when
687     * the nodes themselves are reclaimed.
688     *
689     * Both the parameter <code>data</code> and the returned object are
690     * void pointer, it is applications' responsibility to keep track of
691     * their original type.  Casting them to the wrong type may result
692     * unexpected behavior.
693     *
694     * <p><b>"Experimental - subject to change"</b></p>
695     *
696     * @param key The key to associate the object to.
697     * @param data The object to associate to the given key, or
698     *   <code>null</code> to remove any existing association to that key.
699     * @param handler The handler to associate to that key, or
700     *   <code>null</code>.
701     * @return Returns the void* object previously associated to
702     *   the given key on this node, or <code>null</code> if there was none.
703     * @see #getUserData
704     *
705     * @since DOM Level 3
706     */
707    virtual void*             setUserData(const XMLCh* key,
708                                          void* data,
709                                          DOMUserDataHandler* handler) = 0;
710
711    /**
712     * Retrieves the object associated to a key on a this node. The object
713     * must first have been set to this node by calling
714     * <code>setUserData</code> with the same key.
715     *
716     * <p><b>"Experimental - subject to change"</b></p>
717     *
718     * @param key The key the object is associated to.
719     * @return Returns the <code>void*</code> associated to the given key
720     *   on this node, or <code>null</code> if there was none.
721     * @see #setUserData
722     * @since DOM Level 3
723     */
724    virtual void*             getUserData(const XMLCh* key) const = 0;
725
726
727    /**
728     * The absolute base URI of this node or <code>null</code> if undefined.
729     * This value is computed according to . However, when the
730     * <code>DOMDocument</code> supports the feature "HTML" , the base URI is
731     * computed using first the value of the href attribute of the HTML BASE
732     * element if any, and the value of the <code>documentURI</code>
733     * attribute from the <code>DOMDocument</code> interface otherwise.
734     *
735     * <p><b>"Experimental - subject to change"</b></p>
736     *
737     * <br> When the node is an <code>DOMElement</code>, a <code>DOMDocument</code>
738     * or a a <code>DOMProcessingInstruction</code>, this attribute represents
739     * the properties [base URI] defined in . When the node is a
740     * <code>DOMNotation</code>, an <code>DOMEntity</code>, or an
741     * <code>DOMEntityReference</code>, this attribute represents the
742     * properties [declaration base URI].
743     * @since DOM Level 3
744     */
745    virtual const XMLCh*           getBaseURI() const = 0;
746
747    /**
748     * Compares a node with this node with regard to their position in the
749     * tree and according to the document order. This order can be extended
750     * by module that define additional types of nodes.
751     *
752     * <p><b>"Experimental - subject to change"</b></p>
753     *
754     * @param other The node to compare against this node.
755     * @return Returns how the given node is positioned relatively to this
756     *   node.
757     * @since DOM Level 3
758     */
759    virtual short                  compareTreePosition(const DOMNode* other) const = 0;
760
761    /**
762     * This attribute returns the text content of this node and its
763     * descendants. No serialization is performed, the returned string
764     * does not contain any markup. No whitespace normalization is
765     * performed and the returned string does not contain the white
766     * spaces in element content.
767     *
768     * <p><b>"Experimental - subject to change"</b></p>
769     *
770     * <br>The string returned is made of the text content of this node
771     * depending on its type, as defined below:
772     * <table border='1'>
773     * <tr>
774     * <td>Node type</td>
775     * <td>Content</td>
776     * </tr>
777     * <tr>
778     * <td valign='top' rowspan='1' colspan='1'>
779     * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE,
780     * DOCUMENT_FRAGMENT_NODE</td>
781     * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code>
782     * attribute value of every child node, excluding COMMENT_NODE and
783     * PROCESSING_INSTRUCTION_NODE nodes</td>
784     * </tr>
785     * <tr>
786     * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE,
787     * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td>
788     * <td valign='top' rowspan='1' colspan='1'>
789     * <code>nodeValue</code></td>
790     * </tr>
791     * <tr>
792     * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td>
793     * <td valign='top' rowspan='1' colspan='1'>
794     * null</td>
795     * </tr>
796     * </table>
797     * @exception DOMException
798     *   DOMSTRING_SIZE_ERR: Raised when it would return more characters than
799     *   fit in a <code>DOMString</code> variable on the implementation
800     *   platform.     
801     * @see #setTextContext
802     * @since DOM Level 3
803     */
804    virtual const XMLCh*           getTextContent() const = 0;
805
806    /**
807     * This attribute removes any possible children this node may have and, if the
808     * new string is not empty or null, replaced by a single <code>DOMText</code>
809     * node containing the string this attribute is set to. No parsing is
810     * performed, the input string is taken as pure textual content. 
811     *
812     * <p><b>"Experimental - subject to change"</b></p>
813     *
814     * @exception DOMException
815     *   NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.     
816     * @see #getTextContext
817     * @since DOM Level 3
818     */
819    virtual void                   setTextContent(const XMLCh* textContent) = 0;
820
821    /**
822     * Look up the prefix associated to the given namespace URI, starting from
823     * this node.
824     *
825     * <p><b>"Experimental - subject to change"</b></p>
826     *
827     * @param namespaceURI The namespace URI to look for.
828     * @param useDefault  Indicates if the lookup mechanism should take into
829     *   account the default namespace or not.
830     * @return Returns an associated namespace prefix if found,
831     *   <code>null</code> if none is found and <code>useDefault</code> is
832     *   false, or <code>null</code> if not found or it is the default
833     *   namespace and <code>useDefault</code> is <code>true</code>. If more
834     *   than one prefix are associated to the namespace prefix, the
835     *   returned namespace prefix is implementation dependent.
836     * @since DOM Level 3
837     */
838    virtual const XMLCh*           lookupNamespacePrefix(const XMLCh* namespaceURI,
839                                                         bool useDefault) const = 0;
840
841    /**
842     * This method checks if the specified <code>namespaceURI</code> is the
843     * default namespace or not.
844     *
845     * <p><b>"Experimental - subject to change"</b></p>
846     *
847     * @param namespaceURI The namespace URI to look for.
848     * @return  <code>true</code> if the specified <code>namespaceURI</code>
849     *   is the default namespace, <code>false</code> otherwise.
850     * @since DOM Level 3
851     */
852    virtual bool                   isDefaultNamespace(const XMLCh* namespaceURI) const = 0;
853
854    /**
855     * Look up the namespace URI associated to the given prefix, starting from
856     * this node.
857     *
858     * <p><b>"Experimental - subject to change"</b></p>
859     *
860     * @param prefix The prefix to look for. If this parameter is
861     *   <code>null</code>, the method will return the default namespace URI
862     *   if any.
863     * @return Returns the associated namespace URI or <code>null</code> if
864     *   none is found.
865     * @since DOM Level 3
866     */
867    virtual const XMLCh*           lookupNamespaceURI(const XMLCh* prefix) const  = 0;
868
869    /**
870     * This method makes available a <code>DOMNode</code>'s specialized interface
871     *
872     * <p><b>"Experimental - subject to change"</b></p>
873     *
874     * @param feature The name of the feature requested (case-insensitive).
875     * @return Returns an alternate <code>DOMNode</code> which implements the
876     *   specialized APIs of the specified feature, if any, or
877     *   <code>null</code> if there is no alternate <code>DOMNode</code> which
878     *   implements interfaces associated with that feature. Any alternate
879     *   <code>DOMNode</code> returned by this method must delegate to the
880     *   primary core <code>DOMNode</code> and not return results inconsistent
881     *   with the primary core <code>DOMNode</code> such as <code>key</code>,
882     *   <code>attributes</code>, <code>childNodes</code>, etc.
883     * @since DOM Level 3
884     */
885    virtual DOMNode*               getInterface(const XMLCh* feature) = 0;
886    //@}
887
888    // -----------------------------------------------------------------------
889    //  Non-standard Extension
890    // -----------------------------------------------------------------------
891    /** @name Non-standard Extension */
892    //@{
893    /**
894     * Called to indicate that this Node (and its associated children) is no longer in use
895     * and that the implementation may relinquish any resources associated with it and
896     * its associated children.
897     *
898     * If this is a document, any nodes it owns (created by DOMDocument::createXXXX())
899     * are also released.
900     *
901     * Access to a released object will lead to unexpected result.
902     *
903     * @exception DOMException
904     *   INVALID_ACCESS_ERR: Raised if this Node has a parent and thus should not be released yet.
905     */
906    virtual void              release() = 0;
907    //@}     
908#if defined(XML_DOMREFCOUNT_EXPERIMENTAL)
909    // -----------------------------------------------------------------------
910    //  Non-standard Extension
911    // -----------------------------------------------------------------------
912    /** @name Non-standard Extension */
913    //@{
914    /**
915         * This is custom function which can be implemented by classes deriving
916         * from DOMNode for implementing reference counting on DOMNodes. Any
917         * implementation which has memory management model which involves
918         * disposing of nodes immediately after being used can override this
919         * function to do that job.
920     */
921    virtual void decRefCount() {}
922    //@}
923
924    // -----------------------------------------------------------------------
925    //  Non-standard Extension
926    // -----------------------------------------------------------------------
927    /** @name Non-standard Extension */
928    //@{
929    /**
930         * This is custom function which can be implemented by classes deriving
931         * from DOMNode for implementing reference counting on DOMNodes.
932     */
933    virtual void incRefCount() {}
934    //@}
935#endif
936};
937
938/***
939 * Utilities macros for getting memory manager within DOM
940***/
941#define GET_OWNER_DOCUMENT(ptr)      \
942        ((DOMDocumentImpl*)(ptr->getOwnerDocument()))
943
944#define GET_DIRECT_MM(ptr)           \
945        ptr ? ((DOMDocumentImpl*)ptr)->getMemoryManager() : XMLPlatformUtils::fgMemoryManager       
946
947#define GET_INDIRECT_MM(ptr)                                                    \
948        !ptr ? XMLPlatformUtils::fgMemoryManager :                              \
949        GET_OWNER_DOCUMENT(ptr) ? GET_OWNER_DOCUMENT(ptr)->getMemoryManager() : \
950        XMLPlatformUtils::fgMemoryManager
951
952/***
953 * For DOMNode and its derivatives
954***/
955#define GetDOMNodeMemoryManager GET_INDIRECT_MM(this)
956
957XERCES_CPP_NAMESPACE_END
958
959#endif
960
Note: See TracBrowser for help on using the repository browser.