Xalan-C++ API Reference  1.12.0
XercesDocumentBridge.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(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
19 #define XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680
20 
21 
22 
24 
25 
26 
29 
30 
31 
32 #if XERCES_VERSION_MAJOR >= 2
33 #include <xercesc/dom/deprecated/DOM_Document.hpp>
34 #else
35 #include <xercesc/dom/DOM_Document.hpp>
36 #endif
37 
38 
39 
41 
42 
43 
44 #if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
47 #endif
48 
49 
50 
52 
53 
54 
56 
57 
58 
66 
67 
68 
69 namespace XALAN_CPP_NAMESPACE {
70 
71 
72 
73 class XalanDOMStringPool;
74 class XercesAttrBridge;
75 class XercesCommentBridge;
76 class XercesCDATASectionBridge;
77 class XercesDocumentFragmentBridge;
78 class XercesDocumentTypeBridge;
79 class XercesElementBridge;
80 class XercesEntityBridge;
81 class XercesEntityReferenceBridge;
82 class XercesProcessingInstructionBridge;
83 class XercesNotationBridge;
84 class XercesTextBridge;
85 
86 
87 /**
88  * This class is deprecated.
89  *
90  * @deprecated This class is part of the deprecated Xerces DOM bridge.
91  */
93 {
94 public:
95 
96  friend class XercesBridgeNavigator;
97 
98  /**
99  *
100  * Constructor for XercesDocumentBridge.
101  *
102  * If the document will be shared amongst multiple threads of execution,
103  * the parameter buildBridge must be true. Otherwise, the bridge
104  * nodes will be built on demand, a process which is not synchronized.
105  * This could cause serious problems if multiple threads tried to visit
106  * an unbuilt node at the same time.
107  *
108  * @param theXercesDocument The Xerces document to bridge
109  * @param threadSafe If true, the tree can safely be shared amongst multiple threads. (Also implies buildBridge == true)
110  * @param buildBridge If true, all of the bridge nodes will be built during construction.
111  *
112  */
114  const DOM_Document_Type& theXercesDocument,
115  bool threadSafe = true,
116  bool buildBridge = true);
117 
118  virtual
120 
121  // These interfaces are inherited from XalanNode...
122 
123  virtual const XalanDOMString&
124  getNodeName() const;
125 
126  virtual const XalanDOMString&
127  getNodeValue() const;
128 
129  virtual NodeType
130  getNodeType() const;
131 
132  virtual XalanNode*
133  getParentNode() const;
134 
135  virtual const XalanNodeList*
136  getChildNodes() const;
137 
138  virtual XalanNode*
139  getFirstChild() const;
140 
141  virtual XalanNode*
142  getLastChild() const;
143 
144  virtual XalanNode*
145  getPreviousSibling() const;
146 
147  virtual XalanNode*
148  getNextSibling() const;
149 
150  virtual const XalanNamedNodeMap*
151  getAttributes() const;
152 
153  virtual XalanDocument*
154  getOwnerDocument() const;
155 
156  virtual XercesDocumentBridge*
157  cloneNode(bool deep) const;
158 
159  virtual XalanNode*
160  insertBefore(
161  XalanNode* newChild,
162  XalanNode* refChild);
163 
164  virtual XalanNode*
165  replaceChild(
166  XalanNode* newChild,
167  XalanNode* oldChild);
168 
169  virtual XalanNode*
170  removeChild(XalanNode* oldChild);
171 
172  virtual XalanNode*
173  appendChild(XalanNode* newChild);
174 
175  virtual bool
176  hasChildNodes() const;
177 
178  virtual void
179  setNodeValue(const XalanDOMString& nodeValue);
180 
181  virtual void
182  normalize();
183 
184  virtual bool
185  isSupported(
186  const XalanDOMString& feature,
187  const XalanDOMString& version) const;
188 
189  virtual const XalanDOMString&
190  getNamespaceURI() const;
191 
192  virtual const XalanDOMString&
193  getPrefix() const;
194 
195  virtual const XalanDOMString&
196  getLocalName() const;
197 
198  virtual void
199  setPrefix(const XalanDOMString& prefix);
200 
201  virtual bool
202  isIndexed() const;
203 
204  virtual IndexType
205  getIndex() const;
206 
207  virtual XalanElement*
208  createElement(const XalanDOMString& tagName);
209 
210  virtual XalanDocumentFragment*
211  createDocumentFragment();
212 
213  virtual XalanText*
214  createTextNode(const XalanDOMString& data);
215 
216  virtual XalanComment*
217  createComment(const XalanDOMString& data);
218 
219  virtual XalanCDATASection*
220  createCDATASection(const XalanDOMString& data);
221 
223  createProcessingInstruction(
224  const XalanDOMString& target,
225  const XalanDOMString& data);
226 
227  virtual XalanAttr*
228  createAttribute(const XalanDOMString& name);
229 
230  virtual XalanEntityReference*
231  createEntityReference(const XalanDOMString& name);
232 
233  virtual XalanDocumentType*
234  getDoctype() const;
235 
236  virtual XalanDOMImplementation*
237  getImplementation() const;
238 
239  virtual XalanElement*
240  getDocumentElement() const;
241 
242  virtual XalanNodeList*
243  getElementsByTagName(const XalanDOMString& tagname) const;
244 
245  virtual XalanNode*
246  importNode(
247  XalanNode* importedNode,
248  bool deep);
249 
250  virtual XalanElement*
251  createElementNS(
252  const XalanDOMString& namespaceURI,
253  const XalanDOMString& qualifiedName);
254 
255  virtual XalanAttr*
256  createAttributeNS(
257  const XalanDOMString& namespaceURI,
258  const XalanDOMString& qualifiedName);
259 
260  virtual XalanNodeList*
261  getElementsByTagNameNS(
262  const XalanDOMString& namespaceURI,
263  const XalanDOMString& localName) const;
264 
265  virtual XalanElement*
266  getElementById(const XalanDOMString& elementId) const;
267 
268  // These are some special interfaces to manage relationships between
269  // our nodes and Xerces nodes.
270 
271  /**
272  * Destroy the entire bridge structure that connects
273  * the Xerces document to this XercesDocumentBridge
274  * instance. This will invalidate any pointers to
275  * any nodes in the document (except, of course, the
276  * document itself).
277  */
278  void
279  destroyBridge();
280 
281  /**
282  * Rebuild the entire bridge structure that connects
283  * the Xerces document to this XercesDocumentBridge
284  * instance. This destroys the bridge before
285  * rebuilding.
286  */
287  void
288  rebuildBridge();
289 
290  XalanNode*
291  mapNode(const DOM_NodeType& theXercesNode) const;
292 
293  XalanAttr*
294  mapNode(const DOM_AttrType& theXercesNode) const;
295 
296  XalanElement*
297  mapNode(const DOM_ElementType& theXercesNode) const;
298 
300  mapNode(const XalanNode* theXalanNode) const;
301 
303  mapNode(const XalanAttr* theXalanNode) const;
304 
305  NodeImplType*
306  mapNodeToImpl(const XalanNode* theXalanNode) const;
307 
308  /**
309  *
310  * Get the Xerces DOM_Document that this XercesDocument represents.
311  *
312  * @return the Xerces DOM_Document instance.
313  *
314  */
317  {
318  return m_xercesDocument;
319  }
320 
321  /**
322  * Build the entire bridge structure. This should be done before any
323  * processing begins, if the tree will be shared amongst multiple
324  * threads.
325  */
326  void
327  buildBridgeNodes();
328 
329 
332 
333 
334  // Helper class to walk the tree and build everything...
336  {
337  public:
338 
340 
342  XercesDocumentBridge* theDocument,
343  XercesBridgeNavigator* theDocumentNavigator,
344  NavigatorBridgeVectorInnerType& theNavigators,
345  IndexType theStartIndex);
346 
347  virtual
349 
351  {
353  XercesBridgeNavigator* theNavigator = 0,
354  XalanNode* theNode = 0) :
355  m_navigator(theNavigator),
356  m_node(theNode)
357  {
358  }
359 
361 
363  };
364 
365 
367 
368  protected:
369 
370  virtual void
371  startNode(const DOM_NodeType& node);
372 
373  virtual void
374  endNode(const DOM_NodeType& node);
375 
376  private:
377 
378  XercesDocumentBridge* m_document;
379 
380  NavigatorBridgeVectorInnerType& m_navigators;
381 
382  IndexType m_currentIndex;
383 
384  NavigatorStackType m_parentNavigatorStack;
385 
386  NavigatorStackType m_siblingNavigatorStack;
387  };
388 
389 
390  /**
391  * Get a pooled string. If the string is not in the pool,
392  * add it.
393  *
394  * @param theString The string to pool.
395  * @return A const reference to the pooled string.
396  */
397  const XalanDOMString&
398  getPooledString(const XalanDOMString& theString) const;
399 
400  /**
401  * Get a pooled string. If the string is not in the pool,
402  * add it.
403  *
404  * @param theString The string to pool.
405  * @param theLength The length of the string. If XalanDOMString::npos, the string is assumed to be null-terminated.
406  * @return A const reference to the pooled string.
407  */
408  const XalanDOMString&
409  getPooledString(
410  const XalanDOMChar* theString,
411  XalanDOMString::size_type theLength /* = XalanDOMString::npos */) const;
412 
413 private:
414 
415  XalanNode*
416  mapNode(NodeImplType* theXercesNodeImpl) const;
417 
418  // Destruction API...
419  void
420  destroyBridgeNode(XalanNode* theNode);
421 
422  // Not implemented...
423  XercesDocumentBridge(const XercesDocumentBridge& theSource);
424 
426  operator=(const XercesDocumentBridge& theRHS);
427 
428  bool
429  operator==(const XercesDocumentBridge& theRHS) const;
430 
431  // Private delete function...
432  void
433  destroyNode(XalanNode* theNode);
434 
435  // More internal implementation stuff...
436  XalanNode*
437  internalCloneNode(
438  const XalanNode* theXalanNode,
439  const DOM_NodeType& theXercesNode,
440  bool deep);
441 
442  // Factory methods for our implementation nodes...
443  XalanNode*
444  createBridgeNode(
445  const DOM_NodeType& theXercesNode,
446  IndexType theIndex,
447  bool mapNode) const;
448 
450  createBridgeNode(
451  const DOM_DocumentType_Type& theDoctype,
452  IndexType theIndex,
453  bool mapNode) const;
454 
456  createBridgeNode(
457  const DOM_ElementType& theXercesNode,
458  IndexType theIndex,
459  bool mapNode) const;
460 
462  createBridgeNode(
463  const DOM_DocumentFragmentType& theXercesNode,
464  IndexType theIndex,
465  bool mapNode) const;
466 
468  createBridgeNode(
469  const DOM_TextType& theXercesNode,
470  IndexType theIndex,
471  bool mapNode) const;
472 
474  createBridgeNode(
475  const DOM_CommentType& theXercesNode,
476  IndexType theIndex,
477  bool mapNode) const;
478 
480  createBridgeNode(
481  const DOM_CDATASectionType& theXercesNode,
482  IndexType theIndex,
483  bool mapNode) const;
484 
486  createBridgeNode(
487  const DOM_ProcessingInstructionType& theXercesNode,
488  IndexType theIndex,
489  bool mapNode) const;
490 
492  createBridgeNode(
493  const DOM_AttrType& theXercesNode,
494  IndexType theIndex,
495  bool mapNode) const;
496 
498  createBridgeNode(
499  const DOM_EntityType& theXercesNode,
500  IndexType theIndex,
501  bool mapNode) const;
502 
504  createBridgeNode(
505  const DOM_EntityReferenceType& theXercesNode,
506  IndexType theIndex,
507  bool mapNode) const;
508 
510  createBridgeNode(
511  const DOM_NotationType& theXercesNode,
512  IndexType theIndex,
513  bool mapNode) const;
514 
516  pushNavigator(bool mappingMode) const;
517 
518  // This is a private helper class for building the tree...
519  friend class BuildBridgeTreeWalker;
520 
521  // $$$ ToDo: This is because DOM_Document::getElementById() is not
522  // const...
523  mutable DOM_Document_Type m_xercesDocument;
524 
525  XalanElement* m_documentElement;
526 
527  mutable XercesToXalanNodeMap m_nodeMap;
528 
529  XalanAutoPtr<XalanDOMImplementation> m_domImplementation;
530 
531  mutable NavigatorBridgeVectorType m_navigators;
532 
533  // Our navigator will be the first entry in m_navigators,
534  // but we'll cache this so access is faster...
535  XercesBridgeNavigator* m_navigator;
536 
537  XercesNodeListBridge m_children;
538 
539  mutable NodeVectorType m_nodes;
540 
541  mutable XercesDocumentTypeBridge* m_doctype;
542 
543  bool m_mappingMode;
544 
545  bool m_indexValid;
546 
547  mutable XercesElementBridgeAllocator m_elementAllocator;
548 
549  mutable XercesTextBridgeAllocator m_textAllocator;
550 
551  mutable XercesAttributeBridgeAllocator m_attributeAllocator;
552 
553  const XalanAutoPtr<XalanDOMStringPool> m_stringPool;
554 };
555 
556 
557 
558 }
559 
560 
561 
562 #endif // !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorStackEntryType::NavigatorStackEntryType
NavigatorStackEntryType(XercesBridgeNavigator *theNavigator=0, XalanNode *theNode=0)
Definition: XercesDocumentBridge.hpp:352
xalanc::XalanComment
Definition: XalanComment.hpp:32
xalanc::XercesTreeWalker
This class is deprecated.
Definition: XercesTreeWalker.hpp:38
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorStackEntryType
Definition: XercesDocumentBridge.hpp:350
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker
Definition: XercesDocumentBridge.hpp:335
xalanc::XercesDocumentBridge::NodeVectorType
XalanDeque< XalanNode * > NodeVectorType
Definition: XercesDocumentBridge.hpp:331
xalanc::XalanNode
Definition: XalanNode.hpp:38
xalanc::DOM_ProcessingInstructionType
xercesc::DOM_ProcessingInstruction DOM_ProcessingInstructionType
Definition: XercesBridgeTypes.hpp:79
xalanc::XalanNode::NodeType
NodeType
Definition: XalanNode.hpp:47
xalanc::XalanVector< NavigatorStackEntryType >
xalanc::XalanText
Definition: XalanText.hpp:40
xalanc::XercesCommentBridge
This class is deprecated.
Definition: XercesCommentBridge.hpp:55
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorStackEntryType::m_navigator
XercesBridgeNavigator * m_navigator
Definition: XercesDocumentBridge.hpp:360
XercesTreeWalker.hpp
xalanc::XercesDocumentFragmentBridge
This class is deprecated.
Definition: XercesDocumentFragmentBridge.hpp:55
xalanc::XercesNodeListBridge
This class is deprecated.
Definition: XercesNodeListBridge.hpp:55
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorStackType
XalanVector< NavigatorStackEntryType > NavigatorStackType
Definition: XercesDocumentBridge.hpp:366
XalanDeque.hpp
xalanc::XalanCDATASection
Definition: XalanCDATASection.hpp:32
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
xalanc::XercesDocumentBridge::NavigatorBridgeVectorType
XalanDeque< XercesBridgeNavigator > NavigatorBridgeVectorType
Definition: XercesDocumentBridge.hpp:330
xalanc::NodeImplType
xercesc::NodeImpl NodeImplType
Definition: XercesBridgeTypes.hpp:84
XalanVector.hpp
xalanc::operator==
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
Definition: XalanVector.hpp:1118
xalanc::XercesEntityBridge
This class is deprecated.
Definition: XercesEntityBridge.hpp:55
xalanc::DOM_Document_Type
xercesc::DOM_Document DOM_Document_Type
Definition: XercesDOMWrapperParsedSource.hpp:48
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorBridgeVectorInnerType
NavigatorBridgeVectorType NavigatorBridgeVectorInnerType
Definition: XercesDocumentBridge.hpp:339
XercesTextBridgeAllocator.hpp
xalanc::XercesTextBridgeAllocator
This class is deprecated.
Definition: XercesTextBridgeAllocator.hpp:44
xalanc::XercesAttrBridge
This class is deprecated.
Definition: XercesAttrBridge.hpp:57
xalanc::XalanDeque< XercesBridgeNavigator >
xalanc::XalanNode::IndexType
unsigned long IndexType
Definition: XalanNode.hpp:64
XercesElementBridgeAllocator.hpp
xalanc::XercesElementBridge
This class is deprecated.
Definition: XercesElementBridge.hpp:61
xalanc::XalanDOMImplementation
Definition: XalanDOMImplementation.hpp:45
XalanDOMImplementation.hpp
xalanc::DOM_NodeType
xercesc::DOM_Node DOM_NodeType
Definition: XercesBridgeTypes.hpp:74
xalanc::XalanAttr
Definition: XalanAttr.hpp:40
xalanc::DOM_DocumentFragmentType
xercesc::DOM_DocumentFragment DOM_DocumentFragmentType
Definition: XercesBridgeTypes.hpp:69
xalanc::XercesToXalanNodeMap
This class is deprecated.
Definition: XercesToXalanNodeMap.hpp:62
xalanc::DOM_EntityReferenceType
xercesc::DOM_EntityReference DOM_EntityReferenceType
Definition: XercesBridgeTypes.hpp:73
xalanc::XalanAutoPtr
Definition: XalanAutoPtr.hpp:40
xalanc::DOM_EntityType
xercesc::DOM_Entity DOM_EntityType
Definition: XercesBridgeTypes.hpp:72
XercesParserLiaisonDefinitions.hpp
xalanc::XalanNodeList
Definition: XalanNodeList.hpp:36
xalanc::DOM_TextType
xercesc::DOM_Text DOM_TextType
Definition: XercesBridgeTypes.hpp:75
xalanc::DOM_DocumentType_Type
xercesc::DOM_DocumentType DOM_DocumentType_Type
Definition: XercesBridgeTypes.hpp:67
xalanc::DOM_CDATASectionType
xercesc::DOM_CDATASection DOM_CDATASectionType
Definition: XercesBridgeTypes.hpp:65
XalanAutoPtr.hpp
XalanDocument.hpp
XercesAttributeBridgeAllocator.hpp
xalanc::DOM_CommentType
xercesc::DOM_Comment DOM_CommentType
Definition: XercesBridgeTypes.hpp:64
xalanc::XercesTextBridge
This class is deprecated.
Definition: XercesTextBridge.hpp:54
xalanc::XalanDocumentType
Definition: XalanDocumentType.hpp:40
xalanc::XalanEntityReference
Definition: XalanEntityReference.hpp:40
XALAN_XERCESPARSERLIAISON_EXPORT
#define XALAN_XERCESPARSERLIAISON_EXPORT
Definition: XercesParserLiaisonDefinitions.hpp:39
XalanDOMStringPool.hpp
TreeWalker.hpp
xalanc::DOM_NotationType
xercesc::DOM_Notation DOM_NotationType
Definition: XercesBridgeTypes.hpp:78
XercesToXalanNodeMap.hpp
xalanc::XercesNotationBridge
This class is deprecated.
Definition: XercesNotationBridge.hpp:55
xalanc::XalanElement
Definition: XalanElement.hpp:44
xalanc::XalanNamedNodeMap
Definition: XalanNamedNodeMap.hpp:36
xalanc::XercesBridgeNavigator
This class is deprecated.
Definition: XercesBridgeNavigator.hpp:55
XercesNodeListBridge.hpp
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XercesProcessingInstructionBridge
This class is deprecated.
Definition: XercesProcessingInstructionBridge.hpp:55
xalanc::XercesDocumentBridge::getXercesDocument
DOM_Document_Type getXercesDocument() const
Get the Xerces DOM_Document that this XercesDocument represents.
Definition: XercesDocumentBridge.hpp:316
xalanc::DOM_ElementType
xercesc::DOM_Element DOM_ElementType
Definition: XercesBridgeTypes.hpp:71
XercesBridgeNavigator.hpp
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XercesEntityReferenceBridge
This class is deprecated.
Definition: XercesEntityReferenceBridge.hpp:56
xalanc::XercesAttributeBridgeAllocator
This class is deprecated.
Definition: XercesAttributeBridgeAllocator.hpp:44
xalanc::XercesDocumentBridge
This class is deprecated.
Definition: XercesDocumentBridge.hpp:92
xalanc::XercesDocumentBridge::BuildBridgeTreeWalker::NavigatorStackEntryType::m_node
XalanNode * m_node
Definition: XercesDocumentBridge.hpp:362
xalanc::XalanDocumentFragment
Definition: XalanDocumentFragment.hpp:32
xalanc::DOM_AttrType
xercesc::DOM_Attr DOM_AttrType
Definition: XercesBridgeTypes.hpp:62
xalanc::XercesElementBridgeAllocator
This class is deprecated.
Definition: XercesElementBridgeAllocator.hpp:44
xalanc::XercesCDATASectionBridge
This class is deprecated.
Definition: XercesCDATASectionBridge.hpp:55
xalanc::XalanProcessingInstruction
Definition: XalanProcessingInstruction.hpp:32
xalanc::XercesDocumentTypeBridge
This class is deprecated.
Definition: XercesDocumentTypeBridge.hpp:57