Xalan-C++ API Reference  1.12.0
XercesAttrBridge.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XERCESATTRBRIDGE_HEADER_GUARD_1357924680)
19 #define XERCESATTRBRIDGE_HEADER_GUARD_1357924680
20 
21 
22 
24 
25 
26 
27 #if XERCES_VERSION_MAJOR >= 2
28 #include <xercesc/dom/deprecated/DOM_Attr.hpp>
29 #else
30 #include <xercesc/dom/DOM_Attr.hpp>
31 #endif
32 
33 
34 
36 
37 
38 
41 
42 
43 
44 namespace XALAN_CPP_NAMESPACE {
45 
46 
47 
48 class XercesBridgeNavigator;
49 class XalanElement;
50 
51 
52 /**
53  * This class is deprecated.
54  *
55  * @deprecated This class is part of the deprecated Xerces DOM bridge.
56  */
58 {
59 public:
60 
62  const DOM_AttrType& theXercesAttr,
63  const XercesBridgeNavigator& theNavigator);
64 
65  virtual
67 
68 
69  // These interfaces are inherited from XalanNode...
70  virtual const XalanDOMString&
71  getNodeName() const;
72 
73  /**
74  * Gets the value of this node, depending on its type.
75  */
76  virtual const XalanDOMString&
77  getNodeValue() const;
78 
79  /**
80  * An enum value representing the type of the underlying object.
81  */
82  virtual NodeType
83  getNodeType() const;
84 
85  /**
86  * Gets the parent of this node.
87  *
88  * All nodes, except <code>Document</code>,
89  * <code>DocumentFragment</code>, and <code>Attr</code> may have a parent.
90  * However, if a node has just been created and not yet added to the tree,
91  * or if it has been removed from the tree, a <code>null</code> DOM_Node
92  * is returned.
93  */
94  virtual XalanNode*
95  getParentNode() const;
96 
97  /**
98  * Gets a <code>NodeList</code> that contains all children of this node.
99  *
100  * If there
101  * are no children, this is a <code>NodeList</code> containing no nodes.
102  * The content of the returned <code>NodeList</code> is "live" in the sense
103  * that, for instance, changes to the children of the node object that
104  * it was created from are immediately reflected in the nodes returned by
105  * the <code>NodeList</code> accessors; it is not a static snapshot of the
106  * content of the node. This is true for every <code>NodeList</code>,
107  * including the ones returned by the <code>getElementsByTagName</code>
108  * method.
109  */
110  virtual const XalanNodeList*
111  getChildNodes() const;
112 
113  /**
114  * Gets the first child of this node.
115  *
116  * If there is no such node, this returns <code>null</code>.
117  */
118  virtual XalanNode*
119  getFirstChild() const;
120 
121  /**
122  * Gets the last child of this node.
123  *
124  * If there is no such node, this returns <code>null</code>.
125  */
126  virtual XalanNode*
127  getLastChild() const;
128 
129  /**
130  * Gets the node immediately preceding this node.
131  *
132  * If there is no such node, this returns <code>null</code>.
133  */
134  virtual XalanNode*
136 
137  /**
138  * Gets the node immediately following this node.
139  *
140  * If there is no such node, this returns <code>null</code>.
141  */
142  virtual XalanNode*
143  getNextSibling() const;
144 
145  /**
146  * Gets a <code>NamedNodeMap</code> containing the attributes of this node (if it
147  * is an <code>Element</code>) or <code>null</code> otherwise.
148  */
149  virtual const XalanNamedNodeMap*
150  getAttributes() const;
151 
152  /**
153  * Gets the <code>DOM_Document</code> object associated with this node.
154  *
155  * This is also
156  * the <code>DOM_Document</code> object used to create new nodes. When this
157  * node is a <code>DOM_Document</code> or a <code>DOM_DocumentType</code>
158  * which is not used with any <code>DOM_Document</code> yet, this is
159  * <code>null</code>.
160  */
161  virtual XalanDocument*
163 
164  //@}
165  /** @name Cloning function. */
166  //@{
167 
168  /**
169  * Returns a duplicate of this node.
170  *
171  * This function serves as a generic copy constructor for nodes.
172  *
173  * The duplicate node has no parent (
174  * <code>parentNode</code> returns <code>null</code>.).
175  * <br>Cloning an <code>Element</code> copies all attributes and their
176  * values, including those generated by the XML processor to represent
177  * defaulted attributes, but this method does not copy any text it contains
178  * unless it is a deep clone, since the text is contained in a child
179  * <code>Text</code> node. Cloning any other type of node simply returns a
180  * copy of this node.
181  * @param deep If <code>true</code>, recursively clone the subtree under the
182  * specified node; if <code>false</code>, clone only the node itself (and
183  * its attributes, if it is an <code>Element</code>).
184  * @return The duplicate node.
185  */
186  virtual XercesAttrBridge*
187  cloneNode(bool deep) const;
188 
189  //@}
190  /** @name Functions to modify the DOM Node. */
191  //@{
192 
193  /**
194  * Inserts the node <code>newChild</code> before the existing child node
195  * <code>refChild</code>.
196  *
197  * If <code>refChild</code> is <code>null</code>,
198  * insert <code>newChild</code> at the end of the list of children.
199  * <br>If <code>newChild</code> is a <code>DocumentFragment</code> object,
200  * all of its children are inserted, in the same order, before
201  * <code>refChild</code>. If the <code>newChild</code> is already in the
202  * tree, it is first removed. Note that a <code>DOM_Node</code> that
203  * has never been assigned to refer to an actual node is == null.
204  * @param newChild The node to insert.
205  * @param refChild The reference node, i.e., the node before which the new
206  * node must be inserted.
207  * @return The node being inserted.
208  */
209  virtual XalanNode*
211  XalanNode* newChild,
212  XalanNode* refChild);
213 
214  /**
215  * Replaces the child node <code>oldChild</code> with <code>newChild</code>
216  * in the list of children, and returns the <code>oldChild</code> node.
217  *
218  * If <CODE>newChild</CODE> is a <CODE>DOM_DocumentFragment</CODE> object,
219  * <CODE>oldChild</CODE> is replaced by all of the <CODE>DOM_DocumentFragment</CODE>
220  * children, which are inserted in the same order.
221  *
222  * If the <code>newChild</code> is already in the tree, it is first removed.
223  * @param newChild The new node to put in the child list.
224  * @param oldChild The node being replaced in the list.
225  * @return The node replaced.
226  */
227  virtual XalanNode*
229  XalanNode* newChild,
230  XalanNode* oldChild);
231 
232  /**
233  * Removes the child node indicated by <code>oldChild</code> from the list
234  * of children, and returns it.
235  *
236  * @param oldChild The node being removed.
237  * @return The node removed.
238  */
239  virtual XalanNode*
240  removeChild(XalanNode* oldChild);
241 
242  /**
243  * Adds the node <code>newChild</code> to the end of the list of children of
244  * this node.
245  *
246  * If the <code>newChild</code> is already in the tree, it is
247  * first removed.
248  * @param newChild The node to add.If it is a <code>DocumentFragment</code>
249  * object, the entire contents of the document fragment are moved into
250  * the child list of this node
251  * @return The node added.
252  */
253  virtual XalanNode*
254  appendChild(XalanNode* newChild);
255 
256  //@}
257  /** @name Query functions. */
258  //@{
259 
260  /**
261  * This is a convenience method to allow easy determination of whether a
262  * node has any children.
263  *
264  * @return <code>true</code> if the node has any children,
265  * <code>false</code> if the node has no children.
266  */
267  virtual bool
268  hasChildNodes() const;
269 
270 
271  //@}
272  /** @name Set functions. */
273  //@{
274 
275 
276  /**
277  * Sets the value of the node.
278  *
279  * Any node which can have a nodeValue (@see getNodeValue) will
280  * also accept requests to set it to a string. The exact response to
281  * this varies from node to node -- Attribute, for example, stores
282  * its values in its children and has to replace them with a new Text
283  * holding the replacement value.
284  *
285  * For most types of Node, value is null and attempting to set it
286  * will throw DOMException(NO_MODIFICATION_ALLOWED_ERR). This will
287  * also be thrown if the node is read-only.
288  */
289  virtual void
290  setNodeValue(const XalanDOMString& nodeValue);
291 
292  //@}
293  /** @name Functions introduced in DOM Level 2. */
294  //@{
295 
296  /**
297  * Puts all <CODE>DOM_Text</CODE>
298  * nodes in the full depth of the sub-tree underneath this <CODE>DOM_Node</CODE>,
299  * including attribute nodes, into a "normal" form where only markup (e.g.,
300  * tags, comments, processing instructions, CDATA sections, and entity
301  * references) separates <CODE>DOM_Text</CODE>
302  * nodes, i.e., there are no adjacent <CODE>DOM_Text</CODE>
303  * nodes. This can be used to ensure that the DOM view of a document is the
304  * same as if it were saved and re-loaded, and is useful when operations
305  * (such as XPointer lookups) that depend on a particular document tree
306  * structure are to be used.
307  * <P><B>Note:</B> In cases where the document contains <CODE>DOM_CDATASections</CODE>,
308  * the normalize operation alone may not be sufficient, since XPointers do
309  * not differentiate between <CODE>DOM_Text</CODE>
310  * nodes and <CODE>DOM_CDATASection</CODE> nodes.</P>
311  */
312  virtual void
314 
315  /**
316  * Tests whether the DOM implementation implements a specific
317  * feature and that feature is supported by this node.
318  * @param feature The string of the feature to test. This is the same
319  * name as what can be passed to the method <code>hasFeature</code> on
320  * <code>DOMImplementation</code>.
321  * @param version This is the version number of the feature to test. In
322  * Level 2, version 1, this is the string "2.0". If the version is not
323  * specified, supporting any version of the feature will cause the
324  * method to return <code>true</code>.
325  * @return Returns <code>true</code> if the specified feature is supported
326  * on this node, <code>false</code> otherwise.
327  */
328  virtual bool
330  const XalanDOMString& feature,
331  const XalanDOMString& version) const;
332 
333  /**
334  * Get the <em>namespace URI</em> of
335  * this node, or <code>null</code> if it is unspecified.
336  * <p>
337  * This is not a computed value that is the result of a namespace lookup
338  * based on an examination of the namespace declarations in scope. It is
339  * merely the namespace URI given at creation time.
340  * <p>
341  * For nodes of any type other than <CODE>ELEMENT_NODE</CODE> and
342  * <CODE>ATTRIBUTE_NODE</CODE> and nodes created with a DOM Level 1 method,
343  * such as <CODE>createElement</CODE> from the <CODE>Document</CODE>
344  * interface, this is always <CODE>null</CODE>.
345  */
346  virtual const XalanDOMString&
348 
349  /**
350  * Get the <em>namespace prefix</em>
351  * of this node, or <code>null</code> if it is unspecified.
352  */
353  virtual const XalanDOMString&
354  getPrefix() const;
355 
356  /**
357  * Returns the local part of the <em>qualified name</em> of this node.
358  * <p>
359  * For nodes created with a DOM Level 1 method, such as
360  * <code>createElement</code> from the <code>DOM_Document</code> interface,
361  * it is null.
362  */
363  virtual const XalanDOMString&
364  getLocalName() const;
365 
366  /**
367  * Set the <em>namespace prefix</em> of this node.
368  * <p>
369  * Note that setting this attribute, when permitted, changes
370  * the <CODE>nodeName</CODE> attribute, which holds the <EM>qualified
371  * name</EM>, as well as the <CODE>tagName</CODE> and <CODE>name</CODE>
372  * attributes of the <CODE>DOM_Element</CODE> and <CODE>DOM_Attr</CODE>
373  * interfaces, when applicable.
374  * <p>
375  * Note also that changing the prefix of an
376  * attribute, that is known to have a default value, does not make a new
377  * attribute with the default value and the original prefix appear, since the
378  * <CODE>namespaceURI</CODE> and <CODE>localName</CODE> do not change.
379  *
380  * @param prefix The prefix of this node.
381  * @exception DOMException
382  * INVALID_CHARACTER_ERR: Raised if the specified prefix contains
383  * an illegal character.
384  * <br>
385  * NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
386  * <br>
387  * NAMESPACE_ERR: Raised if the specified <CODE>prefix</CODE> is
388  * malformed, if the specified prefix is "xml" and the
389  * <CODE>namespaceURI</CODE> of this node is different from
390  * "http://www.w3.org/XML/1998/namespace", if specified prefix is
391  * "xmlns" and the <CODE>namespaceURI</CODE> is neither
392  * <CODE>null</CODE> nor an empty string, or if the
393  * <CODE>localName</CODE> is <CODE>null</CODE>.
394  */
395  virtual void
396  setPrefix(const XalanDOMString& prefix);
397 
398  virtual bool
399  isIndexed() const;
400 
401  virtual IndexType
402  getIndex() const;
403 
404  //@}
405 
406  // These interfaces are inherited from XalanAttr...
407 
408  /** @name Getter functions */
409  //@{
410  /**
411 
412  * Returns the name of this attribute.
413  */
414  virtual const XalanDOMString&
415  getName() const;
416 
417  /**
418  *
419  * Returns true if the attribute received its value explicitly in the
420  * XML document, or if a value was assigned programatically with
421  * the setValue function. Returns false if the attribute value
422  * came from the default value declared in the document's DTD.
423  */
424  virtual bool
425  getSpecified() const;
426 
427  /**
428  * Returns the value of the attribute.
429  *
430  * The value of the attribute is returned as a string.
431  * Character and general entity references are replaced with their values.
432  */
433  virtual const XalanDOMString&
434  getValue() const;
435 
436  //@}
437  /** @name Setter functions */
438  //@{
439 
440  /**
441  * Sets the value of the attribute. A text node with the unparsed contents
442  * of the string will be created.
443  *
444  * @param value The value of the DOM attribute to be set
445  */
446  virtual void
447  setValue(const XalanDOMString& value);
448 
449  //@}
450 
451  /** @name Functions introduced in DOM Level 2. */
452  //@{
453  /**
454  * The <code>Element</code> node this attribute is attached to or
455  * <code>null</code> if this attribute is not in use.
456  */
457  virtual XalanElement*
459  //@}
460 
461  /**
462  * Get the Xerces node this instance represent.
463  *
464  * @return The Xerces node
465  */
468  {
469  return m_xercesNode;
470  }
471 
472 private:
473 
474  // Not implemented...
475  XercesAttrBridge(const XercesAttrBridge& theSource);
476 
478  operator=(const XercesAttrBridge& theSource);
479 
480  bool
481  operator==(const XercesAttrBridge& theRHS) const;
482 
483  // Data members...
484  DOM_AttrType m_xercesNode;
485 
486  XercesNodeListBridge m_children;
487 
488  const XercesBridgeNavigator& m_navigator;
489 };
490 
491 
492 
493 }
494 
495 
496 
497 #endif // !defined(XERCESATTRBRIDGE_HEADER_GUARD_1357924680)
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
#define XALAN_XERCESPARSERLIAISON_EXPORT
unsigned long IndexType
Definition: XalanNode.hpp:64
This class is deprecated.
virtual XalanNode * insertBefore(XalanNode *newChild, XalanNode *refChild)
Inserts the node newChild before the existing child node refChild.
virtual XalanNode * getNextSibling() const
Gets the node immediately following this node.
virtual void setValue(const XalanDOMString &value)
Sets the value of the attribute.
DOM_AttrType getXercesNode() const
Get the Xerces node this instance represent.
virtual XalanNode * removeChild(XalanNode *oldChild)
Removes the child node indicated by oldChild from the list of children, and returns it.
virtual bool getSpecified() const
Returns true if the attribute received its value explicitly in the XML document, or if a value was as...
virtual XercesAttrBridge * cloneNode(bool deep) const
Returns a duplicate of this node.
virtual const XalanDOMString & getPrefix() const
Get the namespace prefix of this node, or null if it is unspecified.
XercesAttrBridge(const DOM_AttrType &theXercesAttr, const XercesBridgeNavigator &theNavigator)
virtual IndexType getIndex() const
Get the node's index.
virtual XalanNode * getParentNode() const
Gets the parent of this node.
virtual XalanNode * getLastChild() const
Gets the last child of this node.
virtual const XalanDOMString & getLocalName() const
Returns the local part of the qualified name of this node.
virtual const XalanDOMString & getNodeValue() const
Gets the value of this node, depending on its type.
virtual const XalanDOMString & getValue() const
Returns the value of the attribute.
virtual NodeType getNodeType() const
An enum value representing the type of the underlying object.
virtual void setPrefix(const XalanDOMString &prefix)
Set the namespace prefix of this node.
virtual XalanNode * getFirstChild() const
Gets the first child of this node.
virtual bool isIndexed() const
Determine if the document is node-order indexed.
virtual bool hasChildNodes() const
This is a convenience method to allow easy determination of whether a node has any children.
virtual const XalanDOMString & getName() const
Returns the name of this attribute.
virtual void normalize()
Puts all DOM_Text nodes in the full depth of the sub-tree underneath this DOM_Node,...
virtual const XalanDOMString & getNodeName() const
Gets the name of this node, depending on its type.
virtual void setNodeValue(const XalanDOMString &nodeValue)
Sets the value of the node.
virtual const XalanNodeList * getChildNodes() const
Gets a NodeList that contains all children of this node.
virtual const XalanDOMString & getNamespaceURI() const
Get the namespace URI of this node, or null if it is unspecified.
virtual XalanNode * appendChild(XalanNode *newChild)
Adds the node newChild to the end of the list of children of this node.
virtual XalanElement * getOwnerElement() const
The Element node this attribute is attached to or null if this attribute is not in use.
virtual XalanNode * getPreviousSibling() const
Gets the node immediately preceding this node.
virtual XalanNode * replaceChild(XalanNode *newChild, XalanNode *oldChild)
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node...
virtual XalanDocument * getOwnerDocument() const
Gets the DOM_Document object associated with this node.
virtual bool isSupported(const XalanDOMString &feature, const XalanDOMString &version) const
Tests whether the DOM implementation implements a specific feature and that feature is supported by t...
virtual const XalanNamedNodeMap * getAttributes() const
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
This class is deprecated.
xercesc::DOM_Attr DOM_AttrType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)