Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.10

XercesDocumentBridge.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #if !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
17 #define XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680
18 
19 
20 
22 
23 
24 
27 
28 
29 
30 #if XERCES_VERSION_MAJOR >= 2
31 #include <xercesc/dom/deprecated/DOM_Document.hpp>
32 #else
33 #include <xercesc/dom/DOM_Document.hpp>
34 #endif
35 
36 
37 
39 
40 
41 
42 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
45 #endif
46 
47 
48 
50 
51 
52 
54 
55 
56 
64 
65 
66 
67 XALAN_CPP_NAMESPACE_BEGIN
68 
69 
70 
71 class XalanDOMStringPool;
72 class XercesAttrBridge;
78 class XercesEntityBridge;
82 class XercesTextBridge;
83 
84 
91 {
92 public:
93 
94  friend class XercesBridgeNavigator;
95 
112  const DOM_Document_Type& theXercesDocument,
113  bool threadSafe = true,
114  bool buildBridge = true);
115 
116  virtual
118 
119  // These interfaces are inherited from XalanNode...
120 
121  virtual const XalanDOMString&
122  getNodeName() const;
123 
124  virtual const XalanDOMString&
125  getNodeValue() const;
126 
127  virtual NodeType
128  getNodeType() const;
129 
130  virtual XalanNode*
131  getParentNode() const;
132 
133  virtual const XalanNodeList*
134  getChildNodes() const;
135 
136  virtual XalanNode*
137  getFirstChild() const;
138 
139  virtual XalanNode*
140  getLastChild() const;
141 
142  virtual XalanNode*
143  getPreviousSibling() const;
144 
145  virtual XalanNode*
146  getNextSibling() const;
147 
148  virtual const XalanNamedNodeMap*
149  getAttributes() const;
150 
151  virtual XalanDocument*
152  getOwnerDocument() const;
153 
154 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
155  virtual XalanNode*
156 #else
157  virtual XercesDocumentBridge*
158 #endif
159  cloneNode(bool deep) const;
160 
161  virtual XalanNode*
162  insertBefore(
163  XalanNode* newChild,
164  XalanNode* refChild);
165 
166  virtual XalanNode*
167  replaceChild(
168  XalanNode* newChild,
169  XalanNode* oldChild);
170 
171  virtual XalanNode*
172  removeChild(XalanNode* oldChild);
173 
174  virtual XalanNode*
175  appendChild(XalanNode* newChild);
176 
177  virtual bool
178  hasChildNodes() const;
179 
180  virtual void
181  setNodeValue(const XalanDOMString& nodeValue);
182 
183  virtual void
184  normalize();
185 
186  virtual bool
187  isSupported(
188  const XalanDOMString& feature,
189  const XalanDOMString& version) const;
190 
191  virtual const XalanDOMString&
192  getNamespaceURI() const;
193 
194  virtual const XalanDOMString&
195  getPrefix() const;
196 
197  virtual const XalanDOMString&
198  getLocalName() const;
199 
200  virtual void
201  setPrefix(const XalanDOMString& prefix);
202 
203  virtual bool
204  isIndexed() const;
205 
206  virtual IndexType
207  getIndex() const;
208 
209  virtual XalanElement*
210  createElement(const XalanDOMString& tagName);
211 
212  virtual XalanDocumentFragment*
214 
215  virtual XalanText*
216  createTextNode(const XalanDOMString& data);
217 
218  virtual XalanComment*
219  createComment(const XalanDOMString& data);
220 
221  virtual XalanCDATASection*
222  createCDATASection(const XalanDOMString& data);
223 
226  const XalanDOMString& target,
227  const XalanDOMString& data);
228 
229  virtual XalanAttr*
230  createAttribute(const XalanDOMString& name);
231 
232  virtual XalanEntityReference*
234 
235  virtual XalanDocumentType*
236  getDoctype() const;
237 
238  virtual XalanDOMImplementation*
239  getImplementation() const;
240 
241  virtual XalanElement*
242  getDocumentElement() const;
243 
244  virtual XalanNodeList*
245  getElementsByTagName(const XalanDOMString& tagname) const;
246 
247  virtual XalanNode*
248  importNode(
249  XalanNode* importedNode,
250  bool deep);
251 
252  virtual XalanElement*
254  const XalanDOMString& namespaceURI,
255  const XalanDOMString& qualifiedName);
256 
257  virtual XalanAttr*
259  const XalanDOMString& namespaceURI,
260  const XalanDOMString& qualifiedName);
261 
262  virtual XalanNodeList*
264  const XalanDOMString& namespaceURI,
265  const XalanDOMString& localName) const;
266 
267  virtual XalanElement*
268  getElementById(const XalanDOMString& elementId) const;
269 
270  // These are some special interfaces to manage relationships between
271  // our nodes and Xerces nodes.
272 
280  void
281  destroyBridge();
282 
289  void
290  rebuildBridge();
291 
292  XalanNode*
293  mapNode(const DOM_NodeType& theXercesNode) const;
294 
295  XalanAttr*
296  mapNode(const DOM_AttrType& theXercesNode) const;
297 
298  XalanElement*
299  mapNode(const DOM_ElementType& theXercesNode) const;
300 
302  mapNode(const XalanNode* theXalanNode) const;
303 
305  mapNode(const XalanAttr* theXalanNode) const;
306 
307  NodeImplType*
308  mapNodeToImpl(const XalanNode* theXalanNode) const;
309 
319  {
320  return m_xercesDocument;
321  }
322 
328  void
329  buildBridgeNodes();
330 
331 
334 
335 
336  // Helper class to walk the tree and build everything...
338  {
339  public:
340 
342 
344  XercesDocumentBridge* theDocument,
345  XercesBridgeNavigator* theDocumentNavigator,
346  NavigatorBridgeVectorInnerType& theNavigators,
347  IndexType theStartIndex);
348 
349  virtual
351 
353  {
355  XercesBridgeNavigator* theNavigator = 0,
356  XalanNode* theNode = 0) :
357  m_navigator(theNavigator),
358  m_node(theNode)
359  {
360  }
361 
363 
365  };
366 
367 
369 
370  protected:
371 
372  virtual void
373  startNode(const DOM_NodeType& node);
374 
375  virtual void
376  endNode(const DOM_NodeType& node);
377 
378  private:
379 
380  XercesDocumentBridge* m_document;
381 
382  NavigatorBridgeVectorInnerType& m_navigators;
383 
384  IndexType m_currentIndex;
385 
386  NavigatorStackType m_parentNavigatorStack;
387 
388  NavigatorStackType m_siblingNavigatorStack;
389  };
390 
391 
399  const XalanDOMString&
400  getPooledString(const XalanDOMString& theString) const;
401 
410  const XalanDOMString&
411  getPooledString(
412  const XalanDOMChar* theString,
413  XalanDOMString::size_type theLength /* = XalanDOMString::npos */) const;
414 
415 private:
416 
417  XalanNode*
418  mapNode(NodeImplType* theXercesNodeImpl) const;
419 
420  // Destruction API...
421  void
422  destroyBridgeNode(XalanNode* theNode);
423 
424  // Not implemented...
425  XercesDocumentBridge(const XercesDocumentBridge& theSource);
426 
428  operator=(const XercesDocumentBridge& theRHS);
429 
430  bool
431  operator==(const XercesDocumentBridge& theRHS) const;
432 
433  // Private delete function...
434  void
435  destroyNode(XalanNode* theNode);
436 
437  // More internal implementation stuff...
438  XalanNode*
439  internalCloneNode(
440  const XalanNode* theXalanNode,
441  const DOM_NodeType& theXercesNode,
442  bool deep);
443 
444  // Factory methods for our implementation nodes...
445  XalanNode*
446  createBridgeNode(
447  const DOM_NodeType& theXercesNode,
448  IndexType theIndex,
449  bool mapNode) const;
450 
452  createBridgeNode(
453  const DOM_DocumentType_Type& theDoctype,
454  IndexType theIndex,
455  bool mapNode) const;
456 
458  createBridgeNode(
459  const DOM_ElementType& theXercesNode,
460  IndexType theIndex,
461  bool mapNode) const;
462 
464  createBridgeNode(
465  const DOM_DocumentFragmentType& theXercesNode,
466  IndexType theIndex,
467  bool mapNode) const;
468 
470  createBridgeNode(
471  const DOM_TextType& theXercesNode,
472  IndexType theIndex,
473  bool mapNode) const;
474 
476  createBridgeNode(
477  const DOM_CommentType& theXercesNode,
478  IndexType theIndex,
479  bool mapNode) const;
480 
482  createBridgeNode(
483  const DOM_CDATASectionType& theXercesNode,
484  IndexType theIndex,
485  bool mapNode) const;
486 
488  createBridgeNode(
489  const DOM_ProcessingInstructionType& theXercesNode,
490  IndexType theIndex,
491  bool mapNode) const;
492 
494  createBridgeNode(
495  const DOM_AttrType& theXercesNode,
496  IndexType theIndex,
497  bool mapNode) const;
498 
500  createBridgeNode(
501  const DOM_EntityType& theXercesNode,
502  IndexType theIndex,
503  bool mapNode) const;
504 
506  createBridgeNode(
507  const DOM_EntityReferenceType& theXercesNode,
508  IndexType theIndex,
509  bool mapNode) const;
510 
512  createBridgeNode(
513  const DOM_NotationType& theXercesNode,
514  IndexType theIndex,
515  bool mapNode) const;
516 
518  pushNavigator(bool mappingMode) const;
519 
520  // This is a private helper class for building the tree...
521  friend class BuildBridgeTreeWalker;
522 
523  // $$$ ToDo: This is because DOM_Document::getElementById() is not
524  // const...
525  mutable DOM_Document_Type m_xercesDocument;
526 
527  XalanElement* m_documentElement;
528 
529  mutable XercesToXalanNodeMap m_nodeMap;
530 
531  XalanAutoPtr<XalanDOMImplementation> m_domImplementation;
532 
533  mutable NavigatorBridgeVectorType m_navigators;
534 
535  // Our navigator will be the first entry in m_navigators,
536  // but we'll cache this so access is faster...
537  XercesBridgeNavigator* m_navigator;
538 
539  XercesNodeListBridge m_children;
540 
541  mutable NodeVectorType m_nodes;
542 
543  mutable XercesDocumentTypeBridge* m_doctype;
544 
545  bool m_mappingMode;
546 
547  bool m_indexValid;
548 
549  mutable XercesElementBridgeAllocator m_elementAllocator;
550 
551  mutable XercesTextBridgeAllocator m_textAllocator;
552 
553  mutable XercesAttributeBridgeAllocator m_attributeAllocator;
554 
555  const XalanAutoPtr<XalanDOMStringPool> m_stringPool;
556 };
557 
558 
559 
560 XALAN_CPP_NAMESPACE_END
561 
562 
563 
564 #endif // !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
virtual XalanDOMImplementation * getImplementation() const =0
Return the DOMImplementation object that handles this document.
virtual XalanElement * getDocumentElement() const =0
Return a reference to the root element of the document.
bool operator==(const XalanDocument &theRHS) const
Definition: XalanNode.hpp:44
Definition: XalanNodeList.hpp:42
virtual IndexType getIndex() const =0
Get the node's index.
Definition: XalanText.hpp:38
virtual XalanNode * appendChild(XalanNode *newChild)=0
Adds the node newChild to the end of the list of children of this node.
virtual XalanProcessingInstruction * createProcessingInstruction(const XalanDOMString &target, const XalanDOMString &data)=0
Creates a ProcessingInstruction node given the specified name and data strings.
This class is deprecated.
Definition: XercesTextBridge.hpp:52
This class is deprecated.
Definition: XercesEntityReferenceBridge.hpp:54
This class is deprecated.
Definition: XercesTreeWalker.hpp:36
virtual XalanAttr * createAttributeNS(const XalanDOMString &namespaceURI, const XalanDOMString &qualifiedName)=0
Creates an attribute of the given qualified name and namespace URI.
Definition: XalanAttr.hpp:38
This class is deprecated.
Definition: XercesDocumentBridge.hpp:90
NavigatorStackEntryType(XercesBridgeNavigator *theNavigator=0, XalanNode *theNode=0)
Definition: XercesDocumentBridge.hpp:354
XercesBridgeNavigator * m_navigator
Definition: XercesDocumentBridge.hpp:362
virtual const XalanNodeList * getChildNodes() const =0
Gets a NodeList that contains all children of this node.
virtual XalanNode * insertBefore(XalanNode *newChild, XalanNode *refChild)=0
Inserts the node newChild before the existing child node refChild.
virtual XalanNode * getParentNode() const =0
Gets the parent of this node.
XalanDeque< XalanNode * > NodeVectorType
Definition: XercesDocumentBridge.hpp:333
DOM_Document_Type getXercesDocument() const
Get the Xerces DOM_Document that this XercesDocument represents.
Definition: XercesDocumentBridge.hpp:318
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER DOM_Attr DOM_AttrType
Definition: XercesBridgeTypes.hpp:57
virtual XalanElement * getElementById(const XalanDOMString &elementId) const =0
Returns the Element whose ID is given by elementId.
#define XALAN_XERCESPARSERLIAISON_EXPORT
Definition: XercesParserLiaisonDefinitions.hpp:37
XERCES_CPP_NAMESPACE_QUALIFIER DOM_CDATASection DOM_CDATASectionType
Definition: XercesBridgeTypes.hpp:60
Definition: XalanDocumentFragment.hpp:38
This class is deprecated.
Definition: XercesEntityBridge.hpp:53
This class is deprecated.
Definition: XercesDocumentTypeBridge.hpp:55
Definition: XalanComment.hpp:38
virtual XalanDocument * cloneNode(bool deep) const =0
Returns a duplicate of this node.
virtual XalanDocument * getOwnerDocument() const =0
Gets the Document object associated with this node.
virtual bool isSupported(const XalanDOMString &feature, const XalanDOMString &version) const =0
Tests whether the DOM implementation implements a specific feature and that feature is supported by t...
NodeType
Definition: XalanNode.hpp:53
XERCES_CPP_NAMESPACE_QUALIFIER DOM_DocumentFragment DOM_DocumentFragmentType
Definition: XercesBridgeTypes.hpp:64
Definition: XalanElement.hpp:42
XalanDocument & operator=(const XalanDocument &theSource)
XERCES_CPP_NAMESPACE_QUALIFIER DOM_ProcessingInstruction DOM_ProcessingInstructionType
Definition: XercesBridgeTypes.hpp:74
virtual const XalanDOMString & getLocalName() const =0
Returns the local part of the qualified name of this node.
Definition: XalanCDATASection.hpp:38
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Text DOM_TextType
Definition: XercesBridgeTypes.hpp:70
XalanDeque< XercesBridgeNavigator > NavigatorBridgeVectorType
Definition: XercesDocumentBridge.hpp:332
virtual XalanNode * replaceChild(XalanNode *newChild, XalanNode *oldChild)=0
Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node...
NavigatorBridgeVectorType NavigatorBridgeVectorInnerType
Definition: XercesDocumentBridge.hpp:341
virtual XalanNode * importNode(XalanNode *importedNode, bool deep)=0
Imports a node from another document to this document.
virtual XalanNodeList * getElementsByTagNameNS(const XalanDOMString &namespaceURI, const XalanDOMString &localName) const =0
Returns a NodeList of all the Elements with a given local name and namespace URI in the order in whic...
Definition: XalanDOMStringPool.hpp:37
This class is deprecated.
Definition: XercesAttrBridge.hpp:55
This class is deprecated.
Definition: XercesNodeListBridge.hpp:53
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Notation DOM_NotationType
Definition: XercesBridgeTypes.hpp:73
virtual const XalanDOMString & getNamespaceURI() const =0
Get the namespace URI of this node, or null if it is unspecified.
This class is deprecated.
Definition: XercesProcessingInstructionBridge.hpp:53
virtual void setPrefix(const XalanDOMString &prefix)=0
Set the namespace prefix of this node.
XalanVector< NavigatorStackEntryType > NavigatorStackType
Definition: XercesDocumentBridge.hpp:368
virtual XalanNode * getLastChild() const =0
Gets the last child of this node.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Comment DOM_CommentType
Definition: XercesBridgeTypes.hpp:59
XERCES_CPP_NAMESPACE_QUALIFIER NodeImpl NodeImplType
Definition: XercesBridgeTypes.hpp:79
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Document DOM_Document_Type
Definition: XercesBridgeTypes.hpp:63
XERCES_CPP_NAMESPACE_QUALIFIER DOM_EntityReference DOM_EntityReferenceType
Definition: XercesBridgeTypes.hpp:68
This class is deprecated.
Definition: XercesCDATASectionBridge.hpp:53
Definition: XalanDocumentType.hpp:38
Definition: XalanProcessingInstruction.hpp:38
This class is deprecated.
Definition: XercesCommentBridge.hpp:53
virtual XalanEntityReference * createEntityReference(const XalanDOMString &name)=0
Creates an EntityReference object.
virtual void normalize()=0
Puts all Text nodes in the full depth of the sub-tree underneath this Node, including attribute nodes...
Definition: XalanNamedNodeMap.hpp:42
This class is deprecated.
Definition: XercesTextBridgeAllocator.hpp:42
virtual XalanDocumentFragment * createDocumentFragment()=0
Creates an empty DocumentFragment object.
virtual const XalanDOMString & getNodeValue() const =0
Gets the value of this node, depending on its type.
virtual XalanElement * createElement(const XalanDOMString &tagName)=0
Creates an element of the type specified.
virtual XalanComment * createComment(const XalanDOMString &data)=0
Creates a Comment node given the specified string.
virtual XalanNode * getFirstChild() const =0
Gets the first child of this node.
XalanNode * mapNode(const DOM_NodeType &theXercesNode) const
virtual bool isIndexed() const =0
Determine if the document is node-order indexed.
virtual XalanElement * createElementNS(const XalanDOMString &namespaceURI, const XalanDOMString &qualifiedName)=0
Creates an element of the given qualified name and namespace URI.
virtual XalanText * createTextNode(const XalanDOMString &data)=0
Creates a Text node given the specified string.
This class is deprecated.
Definition: XercesElementBridgeAllocator.hpp:42
Definition: XalanDocument.hpp:51
XalanNode * m_node
Definition: XercesDocumentBridge.hpp:364
virtual const XalanDOMString & getPrefix() const =0
Get the namespace prefix of this node, or null if it is unspecified.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Element DOM_ElementType
Definition: XercesBridgeTypes.hpp:66
XERCES_CPP_NAMESPACE_QUALIFIER DOM_DocumentType DOM_DocumentType_Type
Definition: XercesBridgeTypes.hpp:62
This class is deprecated.
Definition: XercesDocumentFragmentBridge.hpp:53
virtual XalanDocumentType * getDoctype() const =0
Get Document Type Declaration (see DocumentType) associated with this document.
virtual XalanNode * getNextSibling() const =0
Gets the node immediately following this node.
Definition: XalanDOMImplementation.hpp:43
virtual const XalanNamedNodeMap * getAttributes() const =0
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise...
virtual XalanAttr * createAttribute(const XalanDOMString &name)=0
Creates an Attr of the given name.
Definition: XalanDOMString.hpp:42
virtual XalanNode * getPreviousSibling() const =0
Gets the node immediately preceding this node.
Definition: XalanEntityReference.hpp:38
This class is deprecated.
Definition: XercesAttributeBridgeAllocator.hpp:42
unsigned long IndexType
Definition: XalanNode.hpp:70
virtual const XalanDOMString & getNodeName() const =0
This class is deprecated.
Definition: XercesBridgeNavigator.hpp:53
virtual void setNodeValue(const XalanDOMString &nodeValue)=0
Sets the value of the node.
virtual XalanNode * removeChild(XalanNode *oldChild)=0
Removes the child node indicated by oldChild from the list of children, and returns it...
This class is deprecated.
Definition: XercesNotationBridge.hpp:53
unsigned int size_type
Definition: XalanDOMString.hpp:53
Definition: XercesDocumentBridge.hpp:337
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
virtual bool hasChildNodes() const =0
This is a convenience method to allow easy determination of whether a node has any children...
virtual XalanNodeList * getElementsByTagName(const XalanDOMString &tagname) const =0
Returns a NodeList of all the elements with a given tag name.
virtual XalanCDATASection * createCDATASection(const XalanDOMString &data)=0
Creates a CDATASection node whose value is the specified string.
This class is deprecated.
Definition: XercesElementBridge.hpp:59
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Node DOM_NodeType
Definition: XercesBridgeTypes.hpp:69
This class is deprecated.
Definition: XercesToXalanNodeMap.hpp:57
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Entity DOM_EntityType
Definition: XercesBridgeTypes.hpp:67

Interpreting class diagrams

Doxygen and GraphViz are used to generate this API documentation from the Xalan-C header files.

dot

Xalan-C++ XSLT Processor Version 1.10
Copyright © 1999-2004 The Apache Software Foundation. All Rights Reserved.

Apache Logo