Xalan-C++ API Reference  1.12.0
XalanSourceTreeParserLiaison.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(XALANSOURCETREEPARSERLIAISON_HEADER_GUARD_1357924680)
19 #define XALANSOURCETREEPARSERLIAISON_HEADER_GUARD_1357924680
20 
21 
22 // Base include file. Must be first.
24 
25 
26 
28 
29 
30 
33 
34 
35 
36 namespace XERCES_CPP_NAMESPACE
37 {
38  class ContentHandler;
39  class DTDHandler;
40  class LexicalHandler;
41  class SAX2XMLReaderImpl;
42 }
43 
44 
45 
46 namespace XALAN_CPP_NAMESPACE {
47 
48 
49 
50 class XalanSourceTreeDOMSupport;
51 class XalanSourceTreeDocument;
52 
53 
54 
55 /*
56 typedef xercesc::ContentHandler ContentHandlerType;
57 typedef xercesc::DTDHandler DTDHandlerType;
58 typedef xercesc::LexicalHandler LexicalHandlerType;
59 typedef xercesc::SAX2XMLReader SAX2XMLReaderType;
60 */
61 
62 using xercesc::ContentHandler;
63 using xercesc::DTDHandler;
64 using xercesc::LexicalHandler;
65 using xercesc::SAX2XMLReaderImpl;
66 
67 
69 {
70 
71 public:
72 
73  /**
74  * Construct a XalanSourceTreeParserLiaison instance.
75  *
76  * @param theSupport instance of DOMSupport object
77  *
78  * @deprecated This constructor is deprecated. Use the next constructor instead.
79  */
81  XalanSourceTreeDOMSupport& theSupport,
82  MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
83 
84  /**
85  * Construct a XalanSourceTreeParserLiaison instance.
86  */
87  XalanSourceTreeParserLiaison(MemoryManager& theManager XALAN_DEFAULT_MEMMGR);
88 
89  MemoryManager&
91  {
92  return m_documentMap.getMemoryManager();
93  }
94 
95  virtual
97 
98  /**
99  * Get the value of the flag which determines if the data of all
100  * text nodes are pooled, or just whitespace text nodes.
101  *
102  * @return true if the data of all text nodes are pooled, false otherwise.
103  */
104  bool
106  {
107  return m_poolAllText;
108  }
109 
110  /**
111  * Set the value of the flag which determines if the data of all
112  * text nodes are pooled, or just whitespace text nodes.
113  *
114  * @param fValue The new value for the flag.
115  */
116  void
117  setPoolAllText(bool fValue)
118  {
119  m_poolAllText = fValue;
120  }
121 
122  // These interfaces are inherited from XMLParserLiaison...
123 
124  virtual void
125  reset();
126 
127  virtual ExecutionContext*
128  getExecutionContext() const;
129 
130  virtual void
131  setExecutionContext(ExecutionContext& theContext);
132 
133  virtual XalanDocument*
134  parseXMLStream(
135  const InputSource& reader,
136  const XalanDOMString& identifier = XalanDOMString(XalanMemMgrs::getDummyMemMgr()));
137 
138  virtual void
139  parseXMLStream(
140  const InputSource& inputSource,
141  DocumentHandler& handler,
142  const XalanDOMString& identifier = XalanDOMString(XalanMemMgrs::getDummyMemMgr()));
143 
144  virtual void
145  destroyDocument(XalanDocument* theDocument);
146 
147  virtual int
148  getIndent() const;
149 
150  virtual void
151  setIndent(int i);
152 
153  virtual bool
154  getUseValidation() const;
155 
156  virtual void
157  setUseValidation(bool b);
158 
159  virtual const XalanDOMString&
160  getParserDescription(XalanDOMString& theResult) const;
161 
162  virtual EntityResolver*
163  getEntityResolver() const;
164 
165  virtual void
166  setEntityResolver(EntityResolver* resolver);
167 
168  virtual XMLEntityResolver*
169  getXMLEntityResolver() const;
170 
171  virtual void
172  setXMLEntityResolver(XMLEntityResolver* resolver);
173 
174  virtual ErrorHandler*
175  getErrorHandler() const;
176 
177  virtual void
178  setErrorHandler(ErrorHandler* handler);
179 
180 
181  // These interfaces are new to XalanSourceTreeParserLiaison...
182 
183  /**
184  * Parse using a SAX2 ContentHandler, DTDHandler, and LexicalHandler.
185  *
186  * @param theInputSource The input source for the parser
187  * @param theContentHandler The ContentHandler to use
188  * @param theDTDHandler The DTDHandler to use. May be null.
189  * @param theLexicalHandler The LexicalHandler to use. May be null.
190  * @param identifier Used for error reporting only.
191  */
192  virtual void
193  parseXMLStream(
194  const InputSource& theInputSource,
195  ContentHandler& theContentHandler,
196  const XalanDOMString& theIdentifier,
197  DTDHandler* theDTDHandler = 0,
198  LexicalHandler* theLexicalHandler = 0);
199 
200  virtual DOMDocument_Type*
201  createDOMFactory();
202 
203  virtual void
204  destroyDocument(DOMDocument_Type* theDocument);
205 
206  /** Get the 'include ignorable whitespace' flag.
207  *
208  * This method returns the state of the parser's include ignorable
209  * whitespace flag.
210  *
211  * @return 'true' if the include ignorable whitespace flag is set on
212  * the parser, 'false' otherwise.
213  *
214  * @see #setIncludeIgnorableWhitespace
215  */
216  virtual bool
217  getIncludeIgnorableWhitespace() const;
218 
219  /** Set the 'include ignorable whitespace' flag
220  *
221  * This method allows the user to specify whether a validating parser
222  * should include ignorable whitespaces as text nodes. It has no effect
223  * on non-validating parsers which always include non-markup text.
224  * <p>When set to true (also the default), ignorable whitespaces will be
225  * added to the DOM tree as text nodes. The method
226  * DOM_Text::isWhitespace() will return true for those text
227  * nodes only.
228  * <p>When set to false, all ignorable whitespace will be discarded and
229  * no text node is added to the DOM tree. Note: applications intended
230  * to process the "xml:space" attribute should not set this flag to false.
231  *
232  * @param include The new state of the include ignorable whitespace
233  * flag.
234  *
235  * @see #getIncludeIgnorableWhitespace
236  */
237  virtual void
238  setIncludeIgnorableWhitespace(bool include);
239 
240  /**
241  * This method returns the state of the parser's namespace
242  * handling capability.
243  *
244  * @return true, if the parser is currently configured to
245  * understand namespaces, false otherwise.
246  *
247  * @see #setDoNamespaces
248  */
249  virtual bool
250  getDoNamespaces() const;
251 
252  /**
253  * This method allows users to enable or disable the parser's
254  * namespace processing. When set to true, parser starts enforcing
255  * all the constraints / rules specified by the NameSpace
256  * specification.
257  *
258  * <p>The parser's default state is: false.</p>
259  *
260  * <p>This flag is ignored by the underlying scanner if the installed
261  * validator indicates that namespace constraints should be
262  * enforced.</p>
263  *
264  * @param newState The value specifying whether NameSpace rules should
265  * be enforced or not.
266  *
267  * @see #getDoNamespaces
268  */
269  virtual void
270  setDoNamespaces(bool newState);
271 
272  /**
273  * This method returns the state of the parser's
274  * exit-on-First-Fatal-Error flag.
275  *
276  * @return true, if the parser is currently configured to
277  * exit on the first fatal error, false otherwise.
278  *
279  * @see #setExitOnFirstFatalError
280  */
281  virtual bool
282  getExitOnFirstFatalError() const;
283 
284  /**
285  * This method allows users to set the parser's behaviour when it
286  * encounters the first fatal error. If set to true, the parser
287  * will exit at the first fatal error. If false, then it will
288  * report the error and continue processing.
289  *
290  * <p>The default value is 'true' and the parser exits on the
291  * first fatal error.</p>
292  *
293  * @param newState The value specifying whether the parser should
294  * continue or exit when it encounters the first
295  * fatal error.
296  *
297  * @see #getExitOnFirstFatalError
298  */
299  virtual void
300  setExitOnFirstFatalError(bool newState);
301 
302  /**
303  * This method returns the location for an external schema document
304  * for parsing.
305  *
306  * @return A string representing the location of the external schema document
307  */
308  virtual const XalanDOMChar*
309  getExternalSchemaLocation() const;
310 
311  /**
312  * This method sets the location for an external schema document
313  * for parsing.
314  *
315  * @param location A string representing the location of the external schema document
316  */
317  virtual void
318  setExternalSchemaLocation(const XalanDOMChar* location);
319 
320  /**
321  * This method returns the location for an external schema document
322  * for parsing.
323  *
324  * @return A string representing the location of the external schema document
325  */
326  virtual const XalanDOMChar*
327  getExternalNoNamespaceSchemaLocation() const;
328 
329  /**
330  * This method sets the location for an external schema document
331  * for parsing.
332  *
333  * @param location A string representing the location of the external schema document
334  */
335  virtual void
336  setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location);
337 
338  /**
339  * Map a pointer to a XalanDocument instance to its implementation
340  * class pointer. Normally, you should have no reason for doing
341  * this. The liaison will return a null pointer if it did not
342  * create the instance passed.
343  *
344  * @param theDocument A pointer to a XalanDocument instance.
345  * @return A pointer to the XalanSourceTreeDocument instance.
346  */
348  mapDocument(const XalanDocument* theDocument) const;
349 
350  /**
351  * Create a XalanSourceTreeDocument instance.
352  *
353  * @return A pointer to the XalanSourceTreeDocument instance.
354  */
356  createXalanSourceTreeDocument();
357 
358  typedef XalanMap<const XalanDocument*,
360 
361 
362 protected:
363 
364  virtual SAX2XMLReaderImpl*
365  createReader();
366 
367 private:
368 
369  void
370  ensureReader();
371 
372 
373  // Not implemented...
375 
377  operator=(const XalanSourceTreeParserLiaison&);
378 
379 
380  // Data members...
381  XercesParserLiaison m_xercesParserLiaison;
382 
383  DocumentMapType m_documentMap;
384 
385  bool m_poolAllText;
386 
387  SAX2XMLReaderImpl* m_xmlReader;
388 };
389 
390 
391 
392 }
393 
394 
395 
396 #endif // XALANSOURCETREEPARSERLIAISON_HEADER_GUARD_1357924680
xalanc::XalanSourceTreeParserLiaison::DocumentMapType
XalanMap< const XalanDocument *, XalanSourceTreeDocument * > DocumentMapType
Definition: XalanSourceTreeParserLiaison.hpp:359
xalanc::XalanSourceTreeParserLiaison::getMemoryManager
MemoryManager & getMemoryManager()
Get a reference to the current MemoryManager instance.
Definition: XalanSourceTreeParserLiaison.hpp:90
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XalanSourceTreeParserLiaison
Definition: XalanSourceTreeParserLiaison.hpp:68
xalanc::XalanSourceTreeDOMSupport
Definition: XalanSourceTreeDOMSupport.hpp:40
xalanc::XalanDocument
Definition: XalanDocument.hpp:36
XALAN_DEFAULT_MEMMGR
#define XALAN_DEFAULT_MEMMGR
Definition: XalanMemoryManagement.hpp:516
XercesDOMSupport.hpp
xalanc::XalanSourceTreeParserLiaison::getPoolAllText
bool getPoolAllText() const
Get the value of the flag which determines if the data of all text nodes are pooled,...
Definition: XalanSourceTreeParserLiaison.hpp:105
xalanc::ExecutionContext
Definition: ExecutionContext.hpp:60
XalanSourceTreeDefinitions.hpp
xalanc::XalanSourceTreeParserLiaison::setPoolAllText
void setPoolAllText(bool fValue)
Set the value of the flag which determines if the data of all text nodes are pooled,...
Definition: XalanSourceTreeParserLiaison.hpp:117
xalanc::XalanMap
Xalan implementation of a hashtable.
Definition: XalanMap.hpp:186
XercesParserLiaison.hpp
xalanc::XMLParserLiaison
Definition: XMLParserLiaison.hpp:68
XalanMap.hpp
XALAN_XALANSOURCETREE_EXPORT
#define XALAN_XALANSOURCETREE_EXPORT
Definition: XalanSourceTreeDefinitions.hpp:35
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XalanSourceTreeDocument
Definition: XalanSourceTreeDocument.hpp:78
xalanc::XercesParserLiaison
Definition: XercesParserLiaison.hpp:74
xalanc::DOMDocument_Type
xercesc::DOMDocument DOMDocument_Type
Definition: XercesDOMWrapperParsedSource.hpp:49