diff options
Diffstat (limited to 'ACEXML/examples/SAXPrint/main.cpp')
-rw-r--r-- | ACEXML/examples/SAXPrint/main.cpp | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ACEXML/examples/SAXPrint/main.cpp b/ACEXML/examples/SAXPrint/main.cpp new file mode 100644 index 00000000000..97f74cf32b6 --- /dev/null +++ b/ACEXML/examples/SAXPrint/main.cpp @@ -0,0 +1,49 @@ +// $Id$ + +#include "Common/FileCharStream.h" +#include "Basic_Parser/Basic_Parser.h" +#include "Print_Handler.h" +#include "SAXPrint_Handler.h" + + +int +main (int argc, char *argv[]) +{ + { + if (argc != 2) + { + cerr << "Usage: SAXPrint <XML filename>" << endl; + return 1; + } + + ACEXML_FileCharStream *fstm = 0; + ACE_NEW_RETURN (fstm, + ACEXML_FileCharStream (), + 1); + + if (fstm->open (argv [1]) != 0) + { + cerr << "Fail to open XML file: " << argv[1] << endl; + return 1; + } + + ACEXML_Basic_Parser parser; + ACEXML_Print_Handler handler; + ACEXML_InputSource input(fstm); + + parser.setContentHandler (&handler); + parser.setDTDHandler (&handler); + parser.setErrorHandler (&handler); + parser.setEntityResolver (&handler); + + ACEXML_Env xmlenv; + + parser.parse (&input, xmlenv); + if (xmlenv.exception ()) + xmlenv.exception ()->print (); + + cout << "\r\r\r"; + + } + return 0; +} |