Xalan-C++ API Documentation

The Xalan C++ XSLT Processor Version 1.11


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 
36 XALAN_CPP_NAMESPACE_BEGIN
37 
38 
39 
40 class PrefixResolver;
41 class Writer;
42 
43 
44 
45 typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType;
46 typedef XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType;
47 
48 XALAN_USING_XERCES(Locator)
49 XALAN_USING_XERCES(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  */
56 class XALAN_PLATFORMSUPPORT_EXPORT FormatterListener : public XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler
57 {
58 public:
59 
60  typedef XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler ParentType;
61 
62  // A handy typedef... Must match DocumentHandler's type for characters(), etc...
63  typedef XalanSize_t size_type;
64 
65  enum eFormat
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 
81  FormatterListener(eFormat theFormat);
82 
83  virtual
85 
86  /**
87  * Get the output format for the instance.
88  *
89  * @return An enum indicating the output format.
90  */
91  eFormat
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
137  setPrefixResolver(const PrefixResolver* thePrefixResolver)
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
152  charactersRaw(
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
187  cdata(
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
204  characters(
205  const XMLCh* const chars,
206  const size_type length) = 0;
207 
208  virtual void
209  endDocument() = 0;
210 
211  virtual void
212  endElement(const XMLCh* const name) = 0;
213 
214  virtual void
215  ignorableWhitespace(
216  const XMLCh* const chars,
217  const size_type length) = 0;
218 
219  virtual void
220  processingInstruction(
221  const XMLCh* const target,
222  const XMLCh* const data) = 0;
223 
224  virtual void
225  resetDocument() = 0;
226 
227  virtual void
228  setDocumentLocator(const Locator* const locator) = 0;
229 
230  virtual void
231  startDocument() = 0;
232 
233  virtual void
234  startElement(
235  const XMLCh* const name,
236  AttributeList& attrs) = 0;
237 
238  virtual Writer*
239  getWriter() const;
240 
241  virtual const XalanDOMString&
242  getDoctypeSystem() const;
243 
244  virtual const XalanDOMString&
245  getDoctypePublic() const;
246 
247  virtual const XalanDOMString&
248  getEncoding() const;
249 
250  virtual const XalanDOMString&
251  getMediaType() const;
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 
263 #if defined(XALAN_INLINE_INITIALIZATION)
264  static const XalanDOMString::size_type s_piTargetLength = 5;
265  static const XalanDOMString::size_type s_piDataLength = 3;
266 #else
269 #endif
270 
271 
272 protected:
273 
274  // Data membmers...
276 
278 
279  /**
280  * Set the output version during serializing.
281  *
282  * @param theVersion XML version of the output
283  */
284  void
286  {
287  m_XMLVersion = theVersion;
288  }
289 
290 private:
291 
292  // Not implemented...
294 
296  operator=(const FormatterListener&);
297 
298  bool
299  operator==(const FormatterListener&) const;
300 
301  // Data membmers...
302  const eFormat m_outputFormat;
303 
304  eXMLVersion m_XMLVersion;
305 };
306 
307 
308 
309 XALAN_CPP_NAMESPACE_END
310 
311 
312 
313 #endif // FORMATTERLISTENER_HEADER_GUARD_1357924680
eXMLVersion getXMLVersion() const
Get the version of XML the FormatterListener is generating.
static const XalanDOMString s_emptyString
XERCES_CPP_NAMESPACE_QUALIFIER DocumentHandler ParentType
static const XalanDOMString::size_type s_piTargetLength
static const XalanDOMString::size_type s_piDataLength
XERCES_CPP_NAMESPACE_QUALIFIER AttributeList AttributeListType
bool isXML1_1Version() const
Determine if the version of XML output is 1.1.
XalanSize_t size_type
A SAX-based formatter interface for the XSL processor.
This class defines an interface for classes that resolve namespace prefixes to their URIs...
XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType
bool operator==(const ElemAttributeSet &theLHS, const ElemAttributeSet &theRHS)
void setPrefixResolver(const PrefixResolver *thePrefixResolver)
Set the PrefixResolver for the FormatterListener.
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
#define XALAN_PLATFORMSUPPORT_EXPORT
void setXMLVersion(eXMLVersion theVersion)
Set the output version during serializing.
XALAN_CPP_NAMESPACE_BEGIN XALAN_USING_XERCES(Locator)
const PrefixResolver * m_prefixResolver
const PrefixResolver * getPrefixResolver() const
Get the PrefixResolver for the FormatterListener.
eFormat getOutputFormat() const
Get the output format for the instance.

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