Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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 XALAN_CPP_NAMESPACE_BEGIN
70 
71 
72 
73 class XalanDOMStringPool;
74 class XercesAttrBridge;
80 class XercesEntityBridge;
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 #if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
157  virtual XalanNode*
158 #else
159  virtual XercesDocumentBridge*
160 #endif
161  cloneNode(bool deep) const;
162 
163  virtual XalanNode*
164  insertBefore(
165  XalanNode* newChild,
166  XalanNode* refChild);
167 
168  virtual XalanNode*
169  replaceChild(
170  XalanNode* newChild,
171  XalanNode* oldChild);
172 
173  virtual XalanNode*
174  removeChild(XalanNode* oldChild);
175 
176  virtual XalanNode*
177  appendChild(XalanNode* newChild);
178 
179  virtual bool
180  hasChildNodes() const;
181 
182  virtual void
183  setNodeValue(const XalanDOMString& nodeValue);
184 
185  virtual void
186  normalize();
187 
188  virtual bool
189  isSupported(
190  const XalanDOMString& feature,
191  const XalanDOMString& version) const;
192 
193  virtual const XalanDOMString&
194  getNamespaceURI() const;
195 
196  virtual const XalanDOMString&
197  getPrefix() const;
198 
199  virtual const XalanDOMString&
200  getLocalName() const;
201 
202  virtual void
203  setPrefix(const XalanDOMString& prefix);
204 
205  virtual bool
206  isIndexed() const;
207 
208  virtual IndexType
209  getIndex() const;
210 
211  virtual XalanElement*
212  createElement(const XalanDOMString& tagName);
213 
214  virtual XalanDocumentFragment*
215  createDocumentFragment();
216 
217  virtual XalanText*
218  createTextNode(const XalanDOMString& data);
219 
220  virtual XalanComment*
221  createComment(const XalanDOMString& data);
222 
223  virtual XalanCDATASection*
224  createCDATASection(const XalanDOMString& data);
225 
227  createProcessingInstruction(
228  const XalanDOMString& target,
229  const XalanDOMString& data);
230 
231  virtual XalanAttr*
232  createAttribute(const XalanDOMString& name);
233 
234  virtual XalanEntityReference*
235  createEntityReference(const XalanDOMString& name);
236 
237  virtual XalanDocumentType*
238  getDoctype() const;
239 
240  virtual XalanDOMImplementation*
241  getImplementation() const;
242 
243  virtual XalanElement*
244  getDocumentElement() const;
245 
246  virtual XalanNodeList*
247  getElementsByTagName(const XalanDOMString& tagname) const;
248 
249  virtual XalanNode*
250  importNode(
251  XalanNode* importedNode,
252  bool deep);
253 
254  virtual XalanElement*
255  createElementNS(
256  const XalanDOMString& namespaceURI,
257  const XalanDOMString& qualifiedName);
258 
259  virtual XalanAttr*
260  createAttributeNS(
261  const XalanDOMString& namespaceURI,
262  const XalanDOMString& qualifiedName);
263 
264  virtual XalanNodeList*
265  getElementsByTagNameNS(
266  const XalanDOMString& namespaceURI,
267  const XalanDOMString& localName) const;
268 
269  virtual XalanElement*
270  getElementById(const XalanDOMString& elementId) const;
271 
272  // These are some special interfaces to manage relationships between
273  // our nodes and Xerces nodes.
274 
275  /**
276  * Destroy the entire bridge structure that connects
277  * the Xerces document to this XercesDocumentBridge
278  * instance. This will invalidate any pointers to
279  * any nodes in the document (except, of course, the
280  * document itself).
281  */
282  void
283  destroyBridge();
284 
285  /**
286  * Rebuild the entire bridge structure that connects
287  * the Xerces document to this XercesDocumentBridge
288  * instance. This destroys the bridge before
289  * rebuilding.
290  */
291  void
292  rebuildBridge();
293 
294  XalanNode*
295  mapNode(const DOM_NodeType& theXercesNode) const;
296 
297  XalanAttr*
298  mapNode(const DOM_AttrType& theXercesNode) const;
299 
300  XalanElement*
301  mapNode(const DOM_ElementType& theXercesNode) const;
302 
304  mapNode(const XalanNode* theXalanNode) const;
305 
307  mapNode(const XalanAttr* theXalanNode) const;
308 
309  NodeImplType*
310  mapNodeToImpl(const XalanNode* theXalanNode) const;
311 
312  /**
313  *
314  * Get the Xerces DOM_Document that this XercesDocument represents.
315  *
316  * @return the Xerces DOM_Document instance.
317  *
318  */
321  {
322  return m_xercesDocument;
323  }
324 
325  /**
326  * Build the entire bridge structure. This should be done before any
327  * processing begins, if the tree will be shared amongst multiple
328  * threads.
329  */
330  void
331  buildBridgeNodes();
332 
333 
336 
337 
338  // Helper class to walk the tree and build everything...
340  {
341  public:
342 
343  typedef NavigatorBridgeVectorType NavigatorBridgeVectorInnerType;
344 
346  XercesDocumentBridge* theDocument,
347  XercesBridgeNavigator* theDocumentNavigator,
348  NavigatorBridgeVectorInnerType& theNavigators,
349  IndexType theStartIndex);
350 
351  virtual
353 
355  {
357  XercesBridgeNavigator* theNavigator = 0,
358  XalanNode* theNode = 0) :
359  m_navigator(theNavigator),
360  m_node(theNode)
361  {
362  }
363 
365 
367  };
368 
369 
371 
372  protected:
373 
374  virtual void
375  startNode(const DOM_NodeType& node);
376 
377  virtual void
378  endNode(const DOM_NodeType& node);
379 
380  private:
381 
382  XercesDocumentBridge* m_document;
383 
384  NavigatorBridgeVectorInnerType& m_navigators;
385 
386  IndexType m_currentIndex;
387 
388  NavigatorStackType m_parentNavigatorStack;
389 
390  NavigatorStackType m_siblingNavigatorStack;
391  };
392 
393 
394  /**
395  * Get a pooled string. If the string is not in the pool,
396  * add it.
397  *
398  * @param theString The string to pool.
399  * @return A const reference to the pooled string.
400  */
401  const XalanDOMString&
402  getPooledString(const XalanDOMString& theString) const;
403 
404  /**
405  * Get a pooled string. If the string is not in the pool,
406  * add it.
407  *
408  * @param theString The string to pool.
409  * @param theLength The length of the string. If XalanDOMString::npos, the string is assumed to be null-terminated.
410  * @return A const reference to the pooled string.
411  */
412  const XalanDOMString&
413  getPooledString(
414  const XalanDOMChar* theString,
415  XalanDOMString::size_type theLength /* = XalanDOMString::npos */) const;
416 
417 private:
418 
419  XalanNode*
420  mapNode(NodeImplType* theXercesNodeImpl) const;
421 
422  // Destruction API...
423  void
424  destroyBridgeNode(XalanNode* theNode);
425 
426  // Not implemented...
427  XercesDocumentBridge(const XercesDocumentBridge& theSource);
428 
430  operator=(const XercesDocumentBridge& theRHS);
431 
432  bool
433  operator==(const XercesDocumentBridge& theRHS) const;
434 
435  // Private delete function...
436  void
437  destroyNode(XalanNode* theNode);
438 
439  // More internal implementation stuff...
440  XalanNode*
441  internalCloneNode(
442  const XalanNode* theXalanNode,
443  const DOM_NodeType& theXercesNode,
444  bool deep);
445 
446  // Factory methods for our implementation nodes...
447  XalanNode*
448  createBridgeNode(
449  const DOM_NodeType& theXercesNode,
450  IndexType theIndex,
451  bool mapNode) const;
452 
454  createBridgeNode(
455  const DOM_DocumentType_Type& theDoctype,
456  IndexType theIndex,
457  bool mapNode) const;
458 
460  createBridgeNode(
461  const DOM_ElementType& theXercesNode,
462  IndexType theIndex,
463  bool mapNode) const;
464 
466  createBridgeNode(
467  const DOM_DocumentFragmentType& theXercesNode,
468  IndexType theIndex,
469  bool mapNode) const;
470 
472  createBridgeNode(
473  const DOM_TextType& theXercesNode,
474  IndexType theIndex,
475  bool mapNode) const;
476 
478  createBridgeNode(
479  const DOM_CommentType& theXercesNode,
480  IndexType theIndex,
481  bool mapNode) const;
482 
484  createBridgeNode(
485  const DOM_CDATASectionType& theXercesNode,
486  IndexType theIndex,
487  bool mapNode) const;
488 
490  createBridgeNode(
491  const DOM_ProcessingInstructionType& theXercesNode,
492  IndexType theIndex,
493  bool mapNode) const;
494 
496  createBridgeNode(
497  const DOM_AttrType& theXercesNode,
498  IndexType theIndex,
499  bool mapNode) const;
500 
502  createBridgeNode(
503  const DOM_EntityType& theXercesNode,
504  IndexType theIndex,
505  bool mapNode) const;
506 
508  createBridgeNode(
509  const DOM_EntityReferenceType& theXercesNode,
510  IndexType theIndex,
511  bool mapNode) const;
512 
514  createBridgeNode(
515  const DOM_NotationType& theXercesNode,
516  IndexType theIndex,
517  bool mapNode) const;
518 
520  pushNavigator(bool mappingMode) const;
521 
522  // This is a private helper class for building the tree...
523  friend class BuildBridgeTreeWalker;
524 
525  // $$$ ToDo: This is because DOM_Document::getElementById() is not
526  // const...
527  mutable DOM_Document_Type m_xercesDocument;
528 
529  XalanElement* m_documentElement;
530 
531  mutable XercesToXalanNodeMap m_nodeMap;
532 
533  XalanAutoPtr<XalanDOMImplementation> m_domImplementation;
534 
535  mutable NavigatorBridgeVectorType m_navigators;
536 
537  // Our navigator will be the first entry in m_navigators,
538  // but we'll cache this so access is faster...
539  XercesBridgeNavigator* m_navigator;
540 
541  XercesNodeListBridge m_children;
542 
543  mutable NodeVectorType m_nodes;
544 
545  mutable XercesDocumentTypeBridge* m_doctype;
546 
547  bool m_mappingMode;
548 
549  bool m_indexValid;
550 
551  mutable XercesElementBridgeAllocator m_elementAllocator;
552 
553  mutable XercesTextBridgeAllocator m_textAllocator;
554 
555  mutable XercesAttributeBridgeAllocator m_attributeAllocator;
556 
557  const XalanAutoPtr<XalanDOMStringPool> m_stringPool;
558 };
559 
560 
561 
562 XALAN_CPP_NAMESPACE_END
563 
564 
565 
566 #endif // !defined(XERCESDOCUMENTBRIDGE_HEADER_GUARD_1357924680)
virtual XalanElement * getDocumentElement() const =0
Return a reference to the root element of the document.
virtual IndexType getIndex() const =0
Get the node&#39;s index.
This class is deprecated.
XalanNode * removeChild(DOM_NodeType &theXercesParent, XalanNode *oldChild) const
This class is deprecated.
This class is deprecated.
NavigatorStackEntryType(XercesBridgeNavigator *theNavigator=0, XalanNode *theNode=0)
DOM_Document_Type getXercesDocument() const
Get the Xerces DOM_Document that this XercesDocument represents.
virtual const XalanNodeList * getChildNodes() const =0
Gets a NodeList that contains all children of this node.
virtual XalanNode * getParentNode() const =0
Gets the parent of this node.
XalanDeque< XalanNode * > NodeVectorType
XALAN_CPP_NAMESPACE_BEGIN typedef XERCES_CPP_NAMESPACE_QUALIFIER DOM_Attr DOM_AttrType
virtual XalanElement * getElementById(const XalanDOMString &elementId) const =0
Returns the Element whose ID is given by elementId.
#define XALAN_XERCESPARSERLIAISON_EXPORT
XERCES_CPP_NAMESPACE_QUALIFIER DOM_CDATASection DOM_CDATASectionType
This class is deprecated.
This class is deprecated.
virtual XalanDocument * getOwnerDocument() const =0
Gets the Document object associated with this node.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_DocumentFragment DOM_DocumentFragmentType
XERCES_CPP_NAMESPACE_QUALIFIER DOM_ProcessingInstruction DOM_ProcessingInstructionType
virtual const XalanDOMString & getLocalName() const =0
Returns the local part of the qualified name of this node.
XalanSize_t size_type
XalanNode * mapNode(const DOM_NodeType &theXercesNode) const
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Text DOM_TextType
XalanDeque< XercesBridgeNavigator > NavigatorBridgeVectorType
XalanNode * cloneNode(const XalanNode *theXalanNode, const DOM_NodeType &theXercesNode, bool deep) const
This class is deprecated.
This class is deprecated.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Notation DOM_NotationType
virtual const XalanDOMString & getNamespaceURI() const =0
Get the namespace URI of this node, or null if it is unspecified.
XalanVector< NavigatorStackEntryType > NavigatorStackType
virtual XalanNode * getLastChild() const =0
Gets the last child of this node.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Comment DOM_CommentType
XERCES_CPP_NAMESPACE_QUALIFIER NodeImpl NodeImplType
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Document DOM_Document_Type
XERCES_CPP_NAMESPACE_QUALIFIER DOM_EntityReference DOM_EntityReferenceType
This class is deprecated.
This class is deprecated.
This class is deprecated.
virtual const XalanDOMString & getNodeValue() const =0
Gets the value of this node, depending on its type.
virtual XalanNode * getFirstChild() const =0
Gets the first child of this node.
XalanNode * replaceChild(DOM_NodeType &theXercesParent, XalanNode *newChild, XalanNode *oldChild) const
virtual bool isIndexed() const =0
Determine if the document is node-order indexed.
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
XERCES_CPP_NAMESPACE_QUALIFIER DOM_DocumentType DOM_DocumentType_Type
virtual XalanNode * getNextSibling() const =0
Gets the node immediately following this node.
virtual const XalanNamedNodeMap * getAttributes() const =0
Gets a NamedNodeMap containing the attributes of this node (if it is an Element) or null otherwise...
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
virtual XalanNode * getPreviousSibling() const =0
Gets the node immediately preceding this node.
unsigned long IndexType
Definition: XalanNode.hpp:64
XalanNode * appendChild(DOM_NodeType &theXercesParent, XalanNode *newChild) const
virtual const XalanDOMString & getNodeName() const =0
Gets the name of this node, depending on its type.
This class is deprecated.
This class is deprecated.
virtual NodeType getNodeType() const =0
An enum value representing the type of the underlying object.
XalanNode * insertBefore(DOM_NodeType &theXercesParent, XalanNode *newChild, XalanNode *refChild) const
This class is deprecated.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Node DOM_NodeType
This class is deprecated.
XERCES_CPP_NAMESPACE_QUALIFIER DOM_Entity DOM_EntityType

Interpreting class diagrams

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

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

Apache Logo