2002-09-02 17:50:43 +02:00
|
|
|
#ifdef _MSC_VER
|
2002-06-21 13:16:28 +02:00
|
|
|
#pragma warning(disable:4786)
|
2002-09-02 17:50:43 +02:00
|
|
|
#endif
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2007-09-05 00:55:47 +02:00
|
|
|
#include "SimpleHandler.hpp"
|
|
|
|
#include <SAX/InputSource.hpp>
|
|
|
|
#include <SAX/helpers/FeatureNames.hpp>
|
2002-06-21 13:16:28 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
////////////////////////////////////////////////
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
{
|
2002-09-02 17:50:43 +02:00
|
|
|
if(argc < 2)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2002-09-02 12:36:21 +02:00
|
|
|
std::cout << "Usage : " << argv[0] << " xmlfile ... " << std::endl;
|
2002-06-21 13:16:28 +02:00
|
|
|
return 0;
|
|
|
|
} // if(argc == 0)
|
|
|
|
|
2002-09-02 17:50:43 +02:00
|
|
|
SimpleHandler myHandler;
|
2007-09-05 11:49:18 +02:00
|
|
|
Arabica::SAX::FeatureNames<std::string> fNames;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
2002-09-02 17:50:43 +02:00
|
|
|
for(int i = 1; i < argc; ++i)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
2007-09-05 11:49:18 +02:00
|
|
|
Arabica::SAX::XMLReader<std::string> parser;
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
try
|
|
|
|
{
|
2002-09-02 12:36:21 +02:00
|
|
|
parser.setFeature(fNames.external_general, true);
|
|
|
|
parser.setFeature(fNames.validation, true);
|
|
|
|
parser.setFeature(fNames.namespaces, true);
|
|
|
|
parser.setFeature(fNames.namespace_prefixes, true);
|
2002-06-21 13:16:28 +02:00
|
|
|
}
|
2007-09-05 11:49:18 +02:00
|
|
|
catch(Arabica::SAX::SAXException& e)
|
2002-06-21 13:16:28 +02:00
|
|
|
{
|
|
|
|
std::cerr << e.what() << std::endl;
|
|
|
|
}
|
|
|
|
|
2002-09-02 12:36:21 +02:00
|
|
|
parser.setContentHandler(myHandler);
|
|
|
|
parser.setDTDHandler(myHandler);
|
|
|
|
parser.setErrorHandler(myHandler);
|
|
|
|
parser.setEntityResolver(myHandler);
|
2007-07-19 18:58:57 +02:00
|
|
|
parser.setDeclHandler(myHandler);
|
|
|
|
parser.setLexicalHandler(myHandler);
|
2002-06-21 13:16:28 +02:00
|
|
|
|
|
|
|
std::string file(argv[i]);
|
|
|
|
|
|
|
|
if(file != "-")
|
2002-09-02 12:36:21 +02:00
|
|
|
{
|
2007-09-05 14:57:07 +02:00
|
|
|
Arabica::SAX::InputSource<std::string> is(file);
|
2002-09-02 12:36:21 +02:00
|
|
|
parser.parse(is);
|
|
|
|
}
|
2002-06-21 13:16:28 +02:00
|
|
|
else
|
|
|
|
{
|
2007-09-05 14:57:07 +02:00
|
|
|
Arabica::SAX::InputSource<std::string> is;
|
2002-06-21 13:16:28 +02:00
|
|
|
is.setSystemId("stdin");
|
|
|
|
is.setByteStream(std::cin);
|
|
|
|
|
2002-09-02 12:36:21 +02:00
|
|
|
parser.parse(is);
|
2002-06-21 13:16:28 +02:00
|
|
|
} //
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} // main
|
|
|
|
|
|
|
|
// end of file
|