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*
146 
147  virtual XalanNode*
148  getNextSibling() const;
149 
150  virtual const XalanNamedNodeMap*
151  getAttributes() const;
152 
153  virtual XalanDocument*
155 
156  virtual XercesDocumentBridge*
157  cloneNode(bool deep) const;
158 
159  virtual XalanNode*
161  XalanNode* newChild,
162  XalanNode* refChild);
163 
164  virtual XalanNode*
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
183 
184  virtual bool
186  const XalanDOMString& feature,
187  const XalanDOMString& version) const;
188 
189  virtual const XalanDOMString&
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*
212 
213  virtual XalanText*
215 
216  virtual XalanComment*
218 
219  virtual XalanCDATASection*
221 
224  const XalanDOMString& target,
225  const XalanDOMString& data);
226 
227  virtual XalanAttr*
229 
230  virtual XalanEntityReference*
232 
233  virtual XalanDocumentType*
234  getDoctype() const;
235 
236  virtual XalanDOMImplementation*
238 
239  virtual XalanElement*
241 
242  virtual XalanNodeList*
243  getElementsByTagName(const XalanDOMString& tagname) const;
244 
245  virtual XalanNode*
247  XalanNode* importedNode,
248  bool deep);
249 
250  virtual XalanElement*
252  const XalanDOMString& namespaceURI,
253  const XalanDOMString& qualifiedName);
254 
255  virtual XalanAttr*
257  const XalanDOMString& namespaceURI,
258  const XalanDOMString& qualifiedName);
259 
260  virtual XalanNodeList*
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
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
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
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&
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)
#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.
This class is deprecated.
XalanVector< NavigatorStackEntryType > NavigatorStackType
virtual void startNode(const DOM_NodeType &node)
BuildBridgeTreeWalker(XercesDocumentBridge *theDocument, XercesBridgeNavigator *theDocumentNavigator, NavigatorBridgeVectorInnerType &theNavigators, IndexType theStartIndex)
virtual void endNode(const DOM_NodeType &node)
This class is deprecated.
XalanNode * mapNode(const DOM_NodeType &theXercesNode) const
virtual XalanEntityReference * createEntityReference(const XalanDOMString &name)
XalanDeque< XercesBridgeNavigator > NavigatorBridgeVectorType
virtual void setNodeValue(const XalanDOMString &nodeValue)
virtual XalanNode * insertBefore(XalanNode *newChild, XalanNode *refChild)
virtual XalanNode * importNode(XalanNode *importedNode, bool deep)
virtual XalanElement * createElementNS(const XalanDOMString &namespaceURI, const XalanDOMString &qualifiedName)
virtual XalanNode * getLastChild() const
Gets the last child of this node.
const XalanDOMString & getPooledString(const XalanDOMString &theString) const
Get a pooled string.
virtual const XalanDOMString & getPrefix() const
Get the namespace prefix of this node, or null if it is unspecified.
void destroyBridge()
Destroy the entire bridge structure that connects the Xerces document to this XercesDocumentBridge in...
virtual bool isSupported(const XalanDOMString &feature, const XalanDOMString &version) const
virtual XalanAttr * createAttribute(const XalanDOMString &name)
virtual XalanAttr * createAttributeNS(const XalanDOMString &namespaceURI, const XalanDOMString &qualifiedName)
virtual XalanNode * getNextSibling() const
Gets the node immediately following this node.
virtual const XalanDOMString & getNodeValue() const
Gets the value of this node, depending on its type.
void buildBridgeNodes()
Build the entire bridge structure.
virtual XalanDocument * getOwnerDocument() const
Gets the Document object associated with this node.
virtual XalanElement * createElement(const XalanDOMString &tagName)
virtual const XalanNamedNodeMap * getAttributes() const
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise.
const XalanDOMString & getPooledString(const XalanDOMChar *theString, XalanDOMString::size_type theLength) const
Get a pooled string.
virtual XalanNode * getPreviousSibling() const
Gets the node immediately preceding this node.
virtual XercesDocumentBridge * cloneNode(bool deep) const
virtual const XalanDOMString & getNodeName() const
Gets the name of this node, depending on its type.
virtual XalanNode * getParentNode() const
Gets the parent of this node.
virtual XalanComment * createComment(const XalanDOMString &data)
XalanElement * mapNode(const DOM_ElementType &theXercesNode) const
virtual XalanText * createTextNode(const XalanDOMString &data)
virtual const XalanNodeList * getChildNodes() const
Gets a NodeList that contains all children of this node.
virtual XalanElement * getElementById(const XalanDOMString &elementId) const
Returns the Element whose ID is given by elementId.
NodeImplType * mapNodeToImpl(const XalanNode *theXalanNode) const
virtual NodeType getNodeType() const
An enum value representing the type of the underlying object.
virtual XalanNode * appendChild(XalanNode *newChild)
virtual XalanDocumentFragment * createDocumentFragment()
virtual XalanElement * getDocumentElement() const
Return a reference to the root element of the document.
XalanAttr * mapNode(const DOM_AttrType &theXercesNode) const
DOM_AttrType mapNode(const XalanAttr *theXalanNode) const
virtual XalanDOMImplementation * getImplementation() const
virtual XalanNode * removeChild(XalanNode *oldChild)
virtual XalanCDATASection * createCDATASection(const XalanDOMString &data)
virtual XalanNodeList * getElementsByTagName(const XalanDOMString &tagname) const
virtual XalanDocumentType * getDoctype() const
DOM_NodeType mapNode(const XalanNode *theXalanNode) const
virtual bool hasChildNodes() const
virtual XalanProcessingInstruction * createProcessingInstruction(const XalanDOMString &target, const XalanDOMString &data)
XalanDeque< XalanNode * > NodeVectorType
DOM_Document_Type getXercesDocument() const
Get the Xerces DOM_Document that this XercesDocument represents.
void rebuildBridge()
Rebuild the entire bridge structure that connects the Xerces document to this XercesDocumentBridge in...
virtual void setPrefix(const XalanDOMString &prefix)
virtual bool isIndexed() const
Determine if the document is node-order indexed.
virtual const XalanDOMString & getLocalName() const
Returns the local part of the qualified name of this node.
XercesDocumentBridge(const DOM_Document_Type &theXercesDocument, bool threadSafe=true, bool buildBridge=true)
Constructor for XercesDocumentBridge.
virtual XalanNode * replaceChild(XalanNode *newChild, XalanNode *oldChild)
virtual const XalanDOMString & getNamespaceURI() const
Get the namespace URI of this node, or null if it is unspecified.
virtual XalanNodeList * getElementsByTagNameNS(const XalanDOMString &namespaceURI, const XalanDOMString &localName) const
virtual IndexType getIndex() const
Get the node's index.
virtual XalanNode * getFirstChild() const
Gets the first child of this node.
This class is deprecated.
This class is deprecated.
This class is deprecated.
This class is deprecated.
This class is deprecated.
This class is deprecated.
This class is deprecated.
xercesc::DOM_CDATASection DOM_CDATASectionType
xercesc::NodeImpl NodeImplType
xercesc::DOM_ProcessingInstruction DOM_ProcessingInstructionType
xercesc::DOM_Attr DOM_AttrType
xercesc::DOM_EntityReference DOM_EntityReferenceType
xercesc::DOM_Element DOM_ElementType
xercesc::DOM_Text DOM_TextType
xercesc::DOM_Node DOM_NodeType
xercesc::DOM_Entity DOM_EntityType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)
xercesc::DOM_Notation DOM_NotationType
xercesc::DOM_DocumentType DOM_DocumentType_Type
xercesc::DOM_Comment DOM_CommentType
xercesc::DOM_Document DOM_Document_Type
xercesc::DOM_DocumentFragment DOM_DocumentFragmentType
NavigatorStackEntryType(XercesBridgeNavigator *theNavigator=0, XalanNode *theNode=0)