Xalan-C++ API Reference 1.12.0
FormatterListener.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(FORMATTERLISTENER_HEADER_GUARD_1357924680)
19#define FORMATTERLISTENER_HEADER_GUARD_1357924680
20
21
22
23// Base include file. Must be first.
25
26
27
28#include <xercesc/sax/DocumentHandler.hpp>
29
30
31
33
34
35
36namespace XALAN_CPP_NAMESPACE {
37
38
39
40class PrefixResolver;
41class Writer;
42
43
44
45typedef xercesc::Locator LocatorType;
46typedef xercesc::AttributeList AttributeListType;
47
48using xercesc::Locator;
49using xercesc::AttributeList;
50
51
52/**
53 * A SAX-based formatter interface for the XSL processor. This interface
54 * will be called as result tree elements are constructed.
55 */
56class XALAN_PLATFORMSUPPORT_EXPORT FormatterListener : public xercesc::DocumentHandler
57{
58public:
59
60 typedef xercesc::DocumentHandler ParentType;
61
62 // A handy typedef... Must match DocumentHandler's type for characters(), etc...
64
66 {
67 OUTPUT_METHOD_NONE = 0,
68 OUTPUT_METHOD_XML = 1,
69 OUTPUT_METHOD_HTML = 2,
70 OUTPUT_METHOD_TEXT = 3,
71 OUTPUT_METHOD_DOM = 4,
72 OUTPUT_METHOD_OTHER = 5
73 };
74
76 {
77 XML_VERSION_1_0 = 0,
78 XML_VERSION_1_1 = 1
79 };
80
82
83 virtual
85
86 /**
87 * Get the output format for the instance.
88 *
89 * @return An enum indicating the output format.
90 */
93 {
94 return m_outputFormat;
95 }
96
97 /**
98 * Get the version of XML the FormatterListener is
99 * generating.
100 *
101 * @return An enum indication the XML version.
102 */
103 eXMLVersion
105 {
106 return m_XMLVersion;
107 }
108
109 /**
110 * Determine if the version of XML output is 1.1.
111 *
112 * @return true if the output version is 1.1, false if not.
113 */
114 bool
116 {
117 return ( XML_VERSION_1_1 == m_XMLVersion );
118 }
119
120 /**
121 * Get the PrefixResolver for the FormatterListener
122 *
123 * @return A pointer to the PrefixResolver, if any.
124 */
125 const PrefixResolver*
127 {
128 return m_prefixResolver;
129 }
130
131 /**
132 * Set the PrefixResolver for the FormatterListener
133 *
134 * @param thePrefixResolver A pointer to the PrefixResolver, if any.
135 */
136 void
138 {
139 m_prefixResolver = thePrefixResolver;
140 }
141
142 /**
143 * Receive notification of character data. If available, when the
144 * disable-output-escaping attribute is used, output raw text without
145 * escaping.
146 *
147 * @param chars pointer to characters from the XML document
148 * @param length number of characters to read from the array
149 * @exception SAXException
150 */
151 virtual void
153 const XMLCh* const chars,
154 const size_type length) = 0;
155
156 /**
157 * Called when a Comment is to be constructed.
158 *
159 * @param data pointer to comment data
160 * @exception SAXException
161 */
162 virtual void
163 comment(const XMLCh* const data) = 0;
164
165 /**
166 * Receive notification of cdata.
167 *
168 * <p>The Parser will call this method to report each chunk of
169 * character data. SAX parsers may return all contiguous character
170 * data in a single chunk, or they may split it into several
171 * chunks; however, all of the characters in any single event
172 * must come from the same external entity, so that the Locator
173 * provides useful information.</p>
174 *
175 * <p>The application must not attempt to read from the array
176 * outside of the specified range.</p>
177 *
178 * <p>Note that some parsers will report whitespace using the
179 * ignorableWhitespace() method rather than this one (validating
180 * parsers must do so).</p>
181 *
182 * @param ch pointer to characters from the XML document
183 * @param length number of characters to read from the array
184 * @exception SAXException
185 */
186 virtual void
188 const XMLCh* const ch,
189 const size_type length) = 0;
190
191 /**
192 * Receive notification of a entityReference.
193 *
194 * @param data pointer to characters from the XML document
195 * @exception SAXException
196 */
197 virtual void
198 entityReference(const XMLCh* const name) = 0;
199
200
201// These methods are inherited from DocumentHandler ...
202
203 virtual void
205 const XMLCh* const chars,
206 const size_type length) = 0;
207
208 virtual void
210
211 virtual void
212 endElement(const XMLCh* const name) = 0;
213
214 virtual void
216 const XMLCh* const chars,
217 const size_type length) = 0;
218
219 virtual void
221 const XMLCh* const target,
222 const XMLCh* const data) = 0;
223
224 virtual void
226
227 virtual void
228 setDocumentLocator(const Locator* const locator) = 0;
229
230 virtual void
232
233 virtual void
235 const XMLCh* const name,
236 AttributeList& attrs) = 0;
237
238 virtual Writer*
239 getWriter() const;
240
241 virtual const XalanDOMString&
243
244 virtual const XalanDOMString&
246
247 virtual const XalanDOMString&
248 getEncoding() const;
249
250 virtual const XalanDOMString&
252
253 virtual int
254 getIndent() const;
255
256
257 // Used when creating PI to work around limitations of
258 // our interfaces...
259 static const XalanDOMChar s_piTarget[];
260
261 static const XalanDOMChar s_piData[];
262
265
266
267protected:
268
269 // Data membmers...
271
273
274 /**
275 * Set the output version during serializing.
276 *
277 * @param theVersion XML version of the output
278 */
279 void
281 {
282 m_XMLVersion = theVersion;
283 }
284
285private:
286
287 // Not implemented...
289
291 operator=(const FormatterListener&);
292
293 bool
294 operator==(const FormatterListener&) const;
295
296 // Data membmers...
297 const eFormat m_outputFormat;
298
299 eXMLVersion m_XMLVersion;
300};
301
302
303
304}
305
306
307
308#endif // FORMATTERLISTENER_HEADER_GUARD_1357924680
#define XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
A SAX-based formatter interface for the XSL processor.
virtual void cdata(const XMLCh *const ch, const size_type length)=0
Receive notification of cdata.
eFormat getOutputFormat() const
Get the output format for the instance.
const PrefixResolver * getPrefixResolver() const
Get the PrefixResolver for the FormatterListener.
virtual void comment(const XMLCh *const data)=0
Called when a Comment is to be constructed.
virtual void charactersRaw(const XMLCh *const chars, const size_type length)=0
Receive notification of character data.
virtual void setDocumentLocator(const Locator *const locator)=0
virtual void ignorableWhitespace(const XMLCh *const chars, const size_type length)=0
bool isXML1_1Version() const
Determine if the version of XML output is 1.1.
virtual void endDocument()=0
static const XalanDOMString::size_type s_piDataLength
virtual const XalanDOMString & getMediaType() const
virtual void startDocument()=0
void setPrefixResolver(const PrefixResolver *thePrefixResolver)
Set the PrefixResolver for the FormatterListener.
static const XalanDOMString s_emptyString
void setXMLVersion(eXMLVersion theVersion)
Set the output version during serializing.
virtual void startElement(const XMLCh *const name, AttributeList &attrs)=0
virtual void characters(const XMLCh *const chars, const size_type length)=0
xercesc::DocumentHandler ParentType
virtual void processingInstruction(const XMLCh *const target, const XMLCh *const data)=0
static const XalanDOMString::size_type s_piTargetLength
eXMLVersion getXMLVersion() const
Get the version of XML the FormatterListener is generating.
virtual void resetDocument()=0
virtual void endElement(const XMLCh *const name)=0
const PrefixResolver * m_prefixResolver
virtual void entityReference(const XMLCh *const name)=0
Receive notification of a entityReference.
virtual Writer * getWriter() const
virtual const XalanDOMString & getDoctypeSystem() const
virtual const XalanDOMString & getEncoding() const
virtual int getIndent() const
virtual const XalanDOMString & getDoctypePublic() const
FormatterListener(eFormat theFormat)
This class defines an interface for classes that resolve namespace prefixes to their URIs.
xercesc::Locator LocatorType
xercesc::AttributeList AttributeListType
bool operator==(const XalanVector< Type > &theLHS, const XalanVector< Type > &theRHS)