3 //=============================================================================
5 * @file XMLFilterImpl.h
7 * @author Nanbor Wang <nanbor@cs.wustl.edu>
9 //=============================================================================
10 #ifndef ACEXML_XMLFILTERIMPL_H
11 #define ACEXML_XMLFILTERIMPL_H
12 #include /**/ "ace/pre.h"
14 #include "ACEXML/common/XMLFilter.h"
15 #include "ACEXML/common/XMLReader.h"
16 #include "ACEXML/common/Locator.h"
17 #include "ACEXML/common/ContentHandler.h"
18 #include "ACEXML/common/DTDHandler.h"
19 #include "ACEXML/common/EntityResolver.h"
20 #include "ACEXML/common/ErrorHandler.h"
23 * @class ACEXML_XMLFilterImpl
25 * @brief ACEXML_XMLFilterImpl
27 * This class is designed to sit between an XMLReader and the client
28 * application's event handlers. By default, it does nothing but pass
29 * requests up to the reader and events on to the handlers unmodified, but
30 * subclasses can override specific methods to modify the event stream or
31 * the configuration requests as they pass through.
33 class ACEXML_Export ACEXML_XMLFilterImpl
34 : public ACEXML_XMLFilter
,
35 public ACEXML_ContentHandler
,
36 public ACEXML_DTDHandler
,
37 public ACEXML_EntityResolver
,
38 public ACEXML_ErrorHandler
42 * Default constructor. Create with no parent.
44 ACEXML_XMLFilterImpl ();
47 * Construct an XML filter with the specified parent.
49 ACEXML_XMLFilterImpl (ACEXML_XMLReader
*parent
);
54 virtual ~ACEXML_XMLFilterImpl ();
57 * Look up the value of a feature.
59 virtual int getFeature (const ACEXML_Char
*name
);
62 * Look up the value of a property.
64 virtual void * getProperty (const ACEXML_Char
*name
);
67 * Parse an XML document.
69 virtual void parse (ACEXML_InputSource
*input
);
72 * Parse an XML document from a system identifier (URI).
74 virtual void parse (const ACEXML_Char
*systemId
);
77 * Set the state of a feature.
79 virtual void setFeature (const ACEXML_Char
*name
, int boolean_value
);
82 * Set the value of a property.
84 virtual void setProperty (const ACEXML_Char
*name
, void *value
);
87 * Get the parent reader.
89 virtual ACEXML_XMLReader
*getParent () const;
92 * Set the parent reader.
94 virtual void setParent (ACEXML_XMLReader
*parent
);
97 * Get the current DTD event handler.
99 virtual ACEXML_DTDHandler
*getDTDHandler () const;
102 * Get the current content event handler.
104 virtual ACEXML_ContentHandler
*getContentHandler () const;
107 * Get the current entity resolver.
109 virtual ACEXML_EntityResolver
*getEntityResolver () const;
112 * Get the current error event handler.
114 virtual ACEXML_ErrorHandler
*getErrorHandler () const;
117 * Set the DTD event handler.
119 virtual void setDTDHandler (ACEXML_DTDHandler
*handler
);
122 * Set the content event handler.
124 virtual void setContentHandler (ACEXML_ContentHandler
*handler
);
127 * Set the entity resolver.
129 virtual void setEntityResolver (ACEXML_EntityResolver
*handler
);
132 * Set the error event handler.
134 virtual void setErrorHandler (ACEXML_ErrorHandler
*handler
);
137 * Receive notification of character data.
139 virtual void characters (const ACEXML_Char
*ch
,
144 * Receive notification of the end of a document.
146 virtual void endDocument ();
149 * Receive notification of the end of an element.
151 virtual void endElement (const ACEXML_Char
*namespaceURI
,
152 const ACEXML_Char
*localName
,
153 const ACEXML_Char
*qName
);
156 * End the scope of a prefix-URI mapping.
158 virtual void endPrefixMapping (const ACEXML_Char
*prefix
);
161 * Receive notification of ignorable whitespace in element content.
163 virtual void ignorableWhitespace (const ACEXML_Char
*ch
,
168 * Receive notification of a processing instruction.
170 virtual void processingInstruction (const ACEXML_Char
*target
,
171 const ACEXML_Char
*data
);
174 * Receive an object for locating the origin of SAX document events.
176 virtual void setDocumentLocator (ACEXML_Locator
*locator
) ;
179 * Receive notification of a skipped entity.
181 virtual void skippedEntity (const ACEXML_Char
*name
);
184 * Receive notification of the beginning of a document.
186 virtual void startDocument ();
189 * Receive notification of the beginning of an element.
191 virtual void startElement (const ACEXML_Char
*namespaceURI
,
192 const ACEXML_Char
*localName
,
193 const ACEXML_Char
*qName
,
194 ACEXML_Attributes
*atts
);
197 * Begin the scope of a prefix-URI Namespace mapping.
199 virtual void startPrefixMapping (const ACEXML_Char
*prefix
,
200 const ACEXML_Char
*uri
);
202 // *** Methods inherit from ACEXML_DTDHandler.
205 * Receive notification of a notation declaration event.
207 virtual void notationDecl (const ACEXML_Char
*name
,
208 const ACEXML_Char
*publicId
,
209 const ACEXML_Char
*systemId
);
212 * Receive notification of an unparsed entity declaration event.
214 virtual void unparsedEntityDecl (const ACEXML_Char
*name
,
215 const ACEXML_Char
*publicId
,
216 const ACEXML_Char
*systemId
,
217 const ACEXML_Char
*notationName
);
219 // Methods inherit from ACEXML_EnitityResolver.
222 * Allow the application to resolve external entities.
224 virtual ACEXML_InputSource
*resolveEntity (const ACEXML_Char
*publicId
,
225 const ACEXML_Char
*systemId
);
227 // Methods inherit from ACEXML_ErrorHandler.
230 * Receive notification of a recoverable error.
232 virtual void error (ACEXML_SAXParseException
&exception
);
235 * Receive notification of a non-recoverable error.
237 virtual void fatalError (ACEXML_SAXParseException
&exception
);
240 * Receive notification of a warning.
242 virtual void warning (ACEXML_SAXParseException
&exception
);
245 // Set up the event handlers of parent parser to this.
246 // Returns -1 if no valid parent is set.
249 ACEXML_XMLReader
*parent_
;
250 // ACEXML_Locator *locator_;
251 ACEXML_EntityResolver
*entityResolver_
;
252 ACEXML_DTDHandler
*dtdHandler_
;
253 ACEXML_ContentHandler
*contentHandler_
;
254 ACEXML_ErrorHandler
*errorHandler_
;
257 #if defined (__ACEXML_INLINE__)
258 # include "ACEXML/common/XMLFilterImpl.inl"
259 #endif /* __ACEXML_INLINE__ */
261 #include /**/ "ace/post.h"
263 #endif /* ACEXML_XMLFILTERIMPL_H */