arabica/examples/DOM/DOMWriter.cpp

78 lines
1.6 KiB
C++
Raw Normal View History

// DOMWriter.cpp : Defines the entry point for the application.
//
#ifdef _MSC_VER
#pragma warning(disable: 4786 4250 4503)
#endif
#include <string>
2007-09-05 00:55:47 +02:00
#include <DOM/SAX2DOM/SAX2DOM.hpp>
#include <SAX/helpers/CatchErrorHandler.hpp>
2007-09-13 23:21:55 +02:00
#include <DOM/io/Stream.hpp>
////////////////////////////////////////////////
int main(int argc, char* argv[])
{
if(argc < 2)
{
std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl;
return 0;
} // if(argc < 2)
{ // narrow
2007-09-05 13:47:13 +02:00
Arabica::SAX2DOM::Parser<std::string> domParser;
2007-09-05 11:49:18 +02:00
Arabica::SAX::CatchErrorHandler<std::string> eh;
2003-10-29 16:52:28 +01:00
domParser.setErrorHandler(eh);
for(int i = 1; i < argc; ++i)
{
std::string file(argv[i]);
Arabica::SAX::InputSource<std::string> is;
is.setSystemId(file);
if(file != "-")
domParser.parse(is);
else
{
is.setSystemId("stdin");
is.setByteStream(std::cin);
domParser.parse(is);
} // if(file != "-")
2003-10-29 16:52:28 +01:00
if(!eh.errorsReported())
{
2007-09-05 13:47:13 +02:00
Arabica::DOM::Document<std::string> doc = domParser.getDocument();
2005-09-28 22:02:00 +02:00
doc.normalize();
2003-10-29 16:52:28 +01:00
std::cout << doc;
2005-11-09 22:13:22 +01:00
}
2003-10-29 16:52:28 +01:00
else
{
std::cerr << eh.errors() << std::endl;
eh.reset();
} // if ...
} // for ...
2005-11-09 22:13:22 +01:00
2003-08-28 14:36:33 +02:00
}
2003-08-28 14:36:33 +02:00
/*
{ // wide
2007-09-05 13:47:13 +02:00
SAX2Arabica::DOM::Parser<std::wstring> domParser;
2007-09-05 11:49:18 +02:00
Arabica::SAX::wInputSource is;
is.setSystemId(L"stdin");
is.setByteStream(std::cin);
domParser.parse(is);
2007-09-05 13:47:13 +02:00
Arabica::DOM::Document<std::wstring> doc = domParser.getDocument();
std::wcout << doc;
}
2003-08-28 14:36:33 +02:00
*/
return 0;
} // main
// end of file