1 //=============================================================================
3 * @file SAXPrint_Handler.h
5 * @author Nanbor Wang <nanbor@cs.wustl.edu>
7 //=============================================================================
9 #ifndef ACEXML_SAXPRINT_HANDLER_H
10 #define ACEXML_SAXPRINT_HANDLER_H
12 #include "ACEXML/common/DefaultHandler.h"
15 * @class ACEXML_SAXPrint_Handler
17 * @brief ACEXML_SAXPrint_Handler is an example SAX event handler.
19 * This SAX event handler try to regenerate the XML document it
20 * reads with correct indentation.
22 class ACEXML_SAXPrint_Handler
: public ACEXML_DefaultHandler
26 * Default constructor.
28 ACEXML_SAXPrint_Handler (const ACEXML_Char
* name
);
33 virtual ~ACEXML_SAXPrint_Handler ();
35 // Methods inherit from ACEXML_ContentHandler.
38 * Receive notification of character data.
40 virtual void characters (const ACEXML_Char
*ch
,
46 * Receive notification of the end of a document.
48 virtual void endDocument ()
52 * Receive notification of the end of an element.
54 virtual void endElement (const ACEXML_Char
*namespaceURI
,
55 const ACEXML_Char
*localName
,
56 const ACEXML_Char
*qName
);
59 * End the scope of a prefix-URI mapping.
61 virtual void endPrefixMapping (const ACEXML_Char
*prefix
);
64 * Receive notification of ignorable whitespace in element content.
66 virtual void ignorableWhitespace (const ACEXML_Char
*ch
,
71 * Receive notification of a processing instruction.
73 virtual void processingInstruction (const ACEXML_Char
*target
,
74 const ACEXML_Char
*data
);
77 * Receive an object for locating the origin of SAX document events.
79 virtual void setDocumentLocator (ACEXML_Locator
*locator
);
82 * Receive notification of a skipped entity.
84 virtual void skippedEntity (const ACEXML_Char
*name
);
87 * Receive notification of the beginning of a document.
89 virtual void startDocument ();
92 * Receive notification of the beginning of an element.
94 virtual void startElement (const ACEXML_Char
*namespaceURI
,
95 const ACEXML_Char
*localName
,
96 const ACEXML_Char
*qName
,
97 ACEXML_Attributes
*atts
);
100 * Begin the scope of a prefix-URI Namespace mapping.
102 virtual void startPrefixMapping (const ACEXML_Char
*prefix
,
103 const ACEXML_Char
*uri
);
105 // *** Methods inherit from ACEXML_DTDHandler.
108 * Receive notification of a notation declaration event.
110 virtual void notationDecl (const ACEXML_Char
*name
,
111 const ACEXML_Char
*publicId
,
112 const ACEXML_Char
*systemId
);
115 * Receive notification of an unparsed entity declaration event.
117 virtual void unparsedEntityDecl (const ACEXML_Char
*name
,
118 const ACEXML_Char
*publicId
,
119 const ACEXML_Char
*systemId
,
120 const ACEXML_Char
*notationName
);
122 // Methods inherit from ACEXML_EnitityResolver.
125 * Allow the application to resolve external entities.
127 virtual ACEXML_InputSource
*resolveEntity (const ACEXML_Char
*publicId
,
128 const ACEXML_Char
*systemId
);
130 // Methods inherit from ACEXML_ErrorHandler.
133 * Receive notification of a recoverable error.
135 virtual void error (ACEXML_SAXParseException
&exception
);
138 * Receive notification of a non-recoverable error.
140 virtual void fatalError (ACEXML_SAXParseException
&exception
);
143 * Receive notification of a warning.
145 virtual void warning (ACEXML_SAXParseException
&exception
);
149 void print_indent ();
153 ACEXML_Char
* fileName_
;
154 ACEXML_Locator
* locator_
;
157 #if defined (__ACEXML_INLINE__)
158 # include "SAXPrint_Handler.inl"
159 #endif /* __ACEXML_INLINE__ */
160 #endif /* ACEXML_SAXPRINT_HANDLER_H */