Xalan-C++ API Reference  1.12.0
FormatterToDeprecatedXercesDOM.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(FORMATTERTODEPRECATEDXERCESDOM_HEADER_GUARD_1357924680)
19 #define FORMATTERTODEPRECATEDXERCESDOM_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
29 
30 
31 
32 // Base class header file.
34 
35 
36 
38 
39 
40 
42 
43 // Required Xerces headers
44 
45 #if XERCES_VERSION_MAJOR >= 2
46 #include <xercesc/dom/deprecated/DOM_Document.hpp>
47 #include <xercesc/dom/deprecated/DOM_DocumentFragment.hpp>
48 #include <xercesc/dom/deprecated/DOM_Element.hpp>
49 #else
50 #include <xercesc/dom/DOM_Document.hpp>
51 #include <xercesc/dom/DOM_DocumentFragment.hpp>
52 #include <xercesc/dom/DOM_Element.hpp>
53 #endif
54 
55 
56 namespace XALAN_CPP_NAMESPACE {
57 
58 
59 
60 /**
61  * This class takes SAX events (in addition to some extra events that SAX
62  * doesn't handle yet) and adds the result to a document or document fragment.
63  *
64  * It is provided as assist developers transition away from the deprecated DOM.
65  *
66  * @deprecated The Xerces DOM bridge is deprecated.
67  */
69 {
70 public:
71 
72  /**
73  * Construct a FormatterToDeprecatedXercesDOM instance. it will add the DOM nodes
74  * to the document fragment.
75  *
76  * @deprecated This API is deprecated and is only provided as a transition tool
77  * @param doc document for nodes
78  * @param docFrag document fragment for nodes
79  * @param currentElement current element for nodes
80  */
82  DOM_Document_Type &doc,
83  DOM_DocumentFragmentType &docFrag,
84  DOM_ElementType &currentElement);
85 
86  /**
87  * Construct a FormatterToDeprecatedXerces DOM instance. it will add the DOM nodes
88  * to the document.
89  *
90  * @deprecated This API is deprecated and is only provided as a transition tool
91  * @param doc document for nodes
92  * @param elem current element for nodes
93  */
95  DOM_Document_Type &doc,
96  DOM_ElementType &currentElement);
97 
98  /**
99  * Construct a FormatterToDeprecatedXercesDOM instance. it will add the DOM nodes
100  * to the document.
101  *
102  * @deprecated This API is deprecated and is only provided as a transition tool
103  * @param doc document for nodes
104  */
106  DOM_Document_Type &doc);
107 
108  virtual
110 
111 
112  // These methods are inherited from DocumentHandler ...
113 
114  virtual void
115  charactersRaw(
116  const XMLCh* const chars,
117  const unsigned int length);
118 
119  virtual void
120  comment(const XMLCh* const data);
121 
122  virtual void
123  cdata(
124  const XMLCh* const ch,
125  const unsigned int length);
126 
127  virtual void
128  entityReference(const XMLCh* const name);
129 
130  virtual void
131  setDocumentLocator(const Locator* const locator);
132 
133  virtual void
134  startDocument();
135 
136  virtual void
137  endDocument();
138 
139  virtual void
140  startElement(
141  const XMLCh* const name,
142  AttributeListType& attrs);
143 
144  virtual void
145  endElement(const XMLCh* const name);
146 
147  virtual void
148  characters(
149  const XMLCh* const chars,
150  const unsigned int length);
151 
152  virtual void
153  ignorableWhitespace(
154  const XMLCh* const chars,
155  const unsigned int length);
156 
157  virtual void
158  processingInstruction(
159  const XMLCh* const target,
160  const XMLCh* const data);
161 
162  virtual void
163  resetDocument();
164 
166  getDocument() const
167  {
168  return m_doc;
169  }
170 
171  void
173  {
174  m_doc = theDocument;
175  }
176 
179  {
180  return m_docFrag;
181  }
182 
183  void
185  {
186  m_docFrag = theDocumentFragment;
187  }
188 
191  {
192  return m_currentElem;
193  }
194 
195  void
197  {
198  m_currentElem = theElement;
199  }
200 
201 private:
202 
203  /**
204  * Process any accumulated text and create a node for it.
205  */
206  void
207  processAccumulatedText();
208 
209  /**
210  * Append a node to the current container.
211  */
212  void
213  append(DOM_NodeType &newNode);
214 
215  /**
216  * Create the appropriate element, complete with attributes set.
217  *
218  * @param theElementName The name for the new element
219  * @param attrs The SAX AttributeList for the new attributes.
220  * @return A pointer to the new instance.
221  */
223  createElement(
224  const XalanDOMChar* theElementName,
225  AttributeListType& attrs);
226 
227  void
228  addAttributes(
229  DOM_ElementType &theElement,
230  AttributeListType& attrs);
231 
232 
233  // Data members...
234  DOM_Document_Type m_doc;
235 
236  DOM_DocumentFragmentType m_docFrag;
237 
238  DOM_ElementType m_currentElem;
239 
240  typedef XalanVector<DOM_ElementType> ElementStackType;
241 
242  ElementStackType m_elemStack;
243 
244  XalanDOMString m_buffer;
245 
246  XalanDOMString m_textBuffer;
247 
248  static const XalanDOMString s_emptyString;
249 };
250 
251 
252 
253 }
254 
255 
256 
257 #endif // FORMATTERTODEPRECATEDXERCESDOM_HEADER_GUARD_1357924680
xalanc::FormatterToDeprecatedXercesDOM::setDocumentFragment
void setDocumentFragment(DOM_DocumentFragmentType &theDocumentFragment)
Definition: FormatterToDeprecatedXercesDOM.hpp:184
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::AttributeListType
xercesc::AttributeList AttributeListType
Definition: AttributeListImpl.hpp:41
xalanc::FormatterToDeprecatedXercesDOM::getDocument
DOM_Document_Type getDocument() const
Definition: FormatterToDeprecatedXercesDOM.hpp:166
XalanDOMString.hpp
xalanc::XalanVector< DOM_ElementType >
FormatterListener.hpp
XalanVector.hpp
xalanc::FormatterToDeprecatedXercesDOM::setCurrentElement
void setCurrentElement(DOM_ElementType &theElement)
Definition: FormatterToDeprecatedXercesDOM.hpp:196
xalanc::DOM_Document_Type
xercesc::DOM_Document DOM_Document_Type
Definition: XercesDOMWrapperParsedSource.hpp:48
xalanc::FormatterToDeprecatedXercesDOM::getDocumentFragment
DOM_DocumentFragmentType getDocumentFragment() const
Definition: FormatterToDeprecatedXercesDOM.hpp:178
xalanc::append
XalanDOMString & append(XalanDOMString &theString, const XalanDOMString &theStringToAppend)
Concatenate two strings.
Definition: DOMStringHelper.hpp:2294
xalanc::DOM_NodeType
xercesc::DOM_Node DOM_NodeType
Definition: XercesBridgeTypes.hpp:74
xalanc::DOM_DocumentFragmentType
xercesc::DOM_DocumentFragment DOM_DocumentFragmentType
Definition: XercesBridgeTypes.hpp:69
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
XercesParserLiaisonDefinitions.hpp
XALAN_XERCESPARSERLIAISON_EXPORT
#define XALAN_XERCESPARSERLIAISON_EXPORT
Definition: XercesParserLiaisonDefinitions.hpp:39
xalanc::FormatterToDeprecatedXercesDOM
This class takes SAX events (in addition to some extra events that SAX doesn't handle yet) and adds t...
Definition: FormatterToDeprecatedXercesDOM.hpp:68
xalanc::FormatterListener
A SAX-based formatter interface for the XSL processor.
Definition: FormatterListener.hpp:56
xalanc::DOM_ElementType
xercesc::DOM_Element DOM_ElementType
Definition: XercesBridgeTypes.hpp:71
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::FormatterToDeprecatedXercesDOM::setDocument
void setDocument(DOM_Document_Type &theDocument)
Definition: FormatterToDeprecatedXercesDOM.hpp:172
xalanc::FormatterToDeprecatedXercesDOM::getCurrentElement
DOM_ElementType getCurrentElement() const
Definition: FormatterToDeprecatedXercesDOM.hpp:190
XercesBridgeTypes.hpp