2002-11-23 20:54:58 +01:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
# pragma warning(disable:4786)
|
|
|
|
#endif
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <SAX/XMLReader.hpp>
|
|
|
|
#include <SAX/helpers/FeatureNames.hpp>
|
|
|
|
#include <SAX/InputSource.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
#include <iostream>
|
2007-09-05 00:55:47 +02:00
|
|
|
#include <SAX/filter/Writer.hpp>
|
|
|
|
#include <SAX/helpers/CatchErrorHandler.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
|
|
|
if(argc < 2)
|
|
|
|
{
|
|
|
|
std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl;
|
|
|
|
return 0;
|
|
|
|
} // if(argc < 2)
|
|
|
|
|
2003-08-27 16:28:41 +02:00
|
|
|
{ // narrow
|
2007-09-05 11:49:18 +02:00
|
|
|
Arabica::SAX::FeatureNames<std::string> fNames;
|
|
|
|
Arabica::SAX::XMLReader<std::string> parser;
|
2007-09-05 14:57:07 +02:00
|
|
|
Arabica::SAX::Writer<std::string> writer(std::cout, 4);
|
2007-09-05 11:49:18 +02:00
|
|
|
Arabica::SAX::CatchErrorHandler<std::string> eh;
|
2003-10-29 16:51:55 +01:00
|
|
|
|
2003-08-27 16:28:41 +02:00
|
|
|
writer.setParent(parser);
|
2003-10-29 16:51:55 +01:00
|
|
|
writer.setErrorHandler(eh);
|
2003-08-27 16:28:41 +02:00
|
|
|
|
|
|
|
for(int i = 1; i < argc; ++i)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2003-08-27 16:28:41 +02:00
|
|
|
std::string file(argv[i]);
|
2007-09-05 14:57:07 +02:00
|
|
|
Arabica::SAX::InputSource<std::string> is;
|
2003-08-27 16:28:41 +02:00
|
|
|
is.setSystemId(file);
|
|
|
|
|
|
|
|
if(file != "-")
|
|
|
|
writer.parse(is);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
is.setSystemId("stdin");
|
|
|
|
is.setByteStream(std::cin);
|
|
|
|
|
|
|
|
writer.parse(is);
|
|
|
|
} // if(file != "-")
|
2003-10-29 16:51:55 +01:00
|
|
|
|
|
|
|
if(eh.errorsReported())
|
|
|
|
{
|
|
|
|
std::cerr << eh.errors() << std::endl;
|
|
|
|
eh.reset();
|
|
|
|
} // if ...
|
2003-08-27 16:28:41 +02:00
|
|
|
} // for ...
|
|
|
|
}
|
2003-08-28 01:06:59 +02:00
|
|
|
|
2002-06-21 13:16:28 +02:00
|
|
|
return 0;
|
|
|
|
} // main
|
|
|
|
|
|
|
|
// end of file
|