Xalan-C++ API Reference 1.12.0
FormatterToSourceTree.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(FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680)
19#define FORMATTERTOSOURCETREE_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
41namespace XALAN_CPP_NAMESPACE {
42
43
44
45class PrefixResolver;
46class XalanNode;
47class XalanSourceTreeDocument;
48class XalanSourceTreeDocumentFragment;
49class XalanSourceTreeElement;
50
51
52
53/**
54 * This class takes SAX events (in addition to some extra events that SAX
55 * doesn't handle yet) and adds the result to a document or document fragment.
56 */
58{
59public:
60
63
64 enum { eDefaultStackSize = 50, eDefaultTextBufferSize = 100 };
65
66 /**
67 * Perform static initialization. See class XalanSourceTreeInit.
68 */
69 static void
70 initialize(MemoryManager& theManager);
71
72 /**
73 * Perform static shut down. See class XalanSourceTreeInit.
74 */
75 static void
77
78
79 /**
80 * Construct a FormatterToSourceTree instance. it will add the nodes
81 * to the document.
82 *
83 * @param theDocument The document for nodes
84 */
85 explicit
89
90 /**
91 * Construct a FormatterToSourceTree instance. it will add the nodes
92 * to the document fragment.
93 *
94 * @param theDocument The document for nodes
95 * @param theDocumentFragment The document fragment for nodes
96 */
100 MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
101
102 virtual
104
105
108 {
109 return m_document;
110 }
111
112 void
117
120 {
121 return m_documentFragment;
122 }
123
124 void
129
132 {
133 return m_currentElement;
134 }
135
136 void
138 {
139 m_currentElement = theElement;
140 }
141
142 // These methods are inherited from DocumentHandler ...
143
144 virtual void
146 const XMLCh* const chars,
147 const size_type length);
148
149 virtual void
150 comment(const XMLCh* const data);
151
152 virtual void
154 const XMLCh* const ch,
155 const size_type length);
156
157 virtual void
159
160 virtual void
161 setDocumentLocator(const Locator* const locator);
162
163 virtual void
165
166 virtual void
168
169 virtual void
171 const XMLCh* const name,
173
174 virtual void
175 endElement(const XMLCh* const name);
176
177 virtual void
179 const XMLCh* const chars,
180 const size_type length);
181
182 virtual void
184 const XMLCh* const chars,
185 const size_type length);
186
187 virtual void
189 const XMLCh* const target,
190 const XMLCh* const data);
191
192 virtual void
194
195private:
196
197 // Some utility functions...
198 void
199 processAccumulatedText();
200
202 createElementNode(
203 const XalanDOMChar* name,
206
207 void
208 doCharacters(
209 const XalanDOMChar* chars,
210 size_type length);
211
212 void
213 doProcessingInstruction(
214 const XalanDOMChar* target,
215 const XalanDOMChar* data);
216
217
218 // Data members...
219 XalanSourceTreeDocument* m_document;
220
221 XalanSourceTreeDocumentFragment* m_documentFragment;
222
223 XalanSourceTreeElement* m_currentElement;
224
225 ElementStackType m_elementStack;
226
227 // The last child appended to the current element. This is
228 // an important optimization, because XalanSourceTreeElement
229 // does not have a pointer to it's last child. Without this,
230 // appending a child becomes a linear search.
231 XalanNode* m_lastChild;
232
233 // Stack of last children appended. There is a one-to-one
234 // correspondance to the entries in m_elementStack.
235 LastChildStackType m_lastChildStack;
236
237 XalanDOMString m_textBuffer;
238};
239
240
241
242}
243
244
245
246#endif // FORMATTERTOSOURCETREE_HEADER_GUARD_1357924680
#define XALAN_DEFAULT_CONSTRUCTOR_MEMMGR
#define XALAN_DEFAULT_MEMMGR
#define XALAN_XALANSOURCETREE_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
A SAX-based formatter interface for the XSL processor.
This class takes SAX events (in addition to some extra events that SAX doesn't handle yet) and adds t...
virtual void processingInstruction(const XMLCh *const target, const XMLCh *const data)
XalanSourceTreeDocumentFragment * getDocumentFragment() const
virtual void setDocumentLocator(const Locator *const locator)
virtual void cdata(const XMLCh *const ch, const size_type length)
Receive notification of cdata.
XalanSourceTreeDocument * getDocument() const
void setDocumentFragment(XalanSourceTreeDocumentFragment *theDocumentFragment)
virtual void entityReference(const XMLCh *const name)
Receive notification of a entityReference.
virtual void characters(const XMLCh *const chars, const size_type length)
virtual void startElement(const XMLCh *const name, AttributeListType &attrs)
XalanVector< XalanSourceTreeElement * > ElementStackType
virtual void ignorableWhitespace(const XMLCh *const chars, const size_type length)
virtual void charactersRaw(const XMLCh *const chars, const size_type length)
Receive notification of character data.
XalanVector< XalanNode * > LastChildStackType
static void terminate()
Perform static shut down.
void setCurrentElement(XalanSourceTreeElement *theElement)
virtual void comment(const XMLCh *const data)
Called when a Comment is to be constructed.
XalanSourceTreeElement * getCurrentElement() const
static void initialize(MemoryManager &theManager)
Perform static initialization.
void setDocument(XalanSourceTreeDocument *theDocument)
FormatterToSourceTree(MemoryManager &theManager XALAN_DEFAULT_CONSTRUCTOR_MEMMGR, XalanSourceTreeDocument *theDocument=0)
Construct a FormatterToSourceTree instance.
FormatterToSourceTree(XalanSourceTreeDocument *theDocument, XalanSourceTreeDocumentFragment *theDocumentFragment, MemoryManager &theManager XALAN_DEFAULT_MEMMGR)
Construct a FormatterToSourceTree instance.
virtual void endElement(const XMLCh *const name)
xercesc::AttributeList AttributeListType