source: icXML/icXML-devel/src/xercesc/dom/DOMNode.hpp @ 2722

Last change on this file since 2722 was 2722, checked in by cameron, 6 years ago

Original Xerces files with import mods for icxercesc

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