Esempio n. 1
0
int main(int argc, char** argv)
{
	// parse an XML document and print the generated SAX events

	if (argc < 2)
	{
		std::cout << "usage: " << argv[0] << ": <xmlfile>" << std::endl;
		return 1;
	}
	
	MyHandler handler;

	SAXParser parser;
	parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
	parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
	parser.setContentHandler(&handler);
	parser.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<LexicalHandler*>(&handler));
	
	try
	{
		parser.parse(argv[1]);
	}
	catch (Poco::Exception& e)
	{
		std::cerr << e.displayText() << std::endl;
		return 2;
	}
	
	return 0;
}
Esempio n. 2
0
			void PSAPAddrTest::setUp() {
#if 0
//
// Macros are defined for now by the Macro constructor
//
				AEISAXHandler handler;
				SAXParser parser;

				parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
				parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
				parser.setContentHandler(&handler);
				parser.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER,	static_cast<LexicalHandler*>(&handler));

				parser.parse("../../../../../../test/iso/itu/osi/als/base/addr/Macros.xml");
#endif
			}
Esempio n. 3
0
int main (int argc, char** argv) {
	if (false) {
		RFC_1006 rfc1006;
		NSAPAddr nsap;
		const char* n = rfc1006.parse(nsap, "+03+10.0.0.6:8080");
		const char*p;
		Selector selector;
		p = selector.parse("////NS+a433bb93c1");
		p = selector.parse("#124/NS");
		p = selector.parse("\"abc\"/NS");
		p = selector.parse("'3a'H/NS");

		string sel = "#124";
		TSAPService		service("echo", "#124", "pippo",  "bar");
		TSAPServices	services;
		services.add("echo", "#12", "pippo", "bar");
		const OSIService* os = services.getServiceBySelector(selector);
		if (os != NULL) {
			os->entity();
		}
	}
	{
		AEISAXHandler handler;
		SAXParser parser;

		parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
		parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
		parser.setContentHandler(&handler);
		parser.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER,	static_cast<LexicalHandler*>(&handler));

		try	{
			parser.parse("AEI.xml");
			ServiceFunctor functor(cout);
			//TSAP_SERVICES.print(functor);
			//SSAP_SERVICES.print(functor);
			//PSAP_SERVICES.print(functor);

			const OSIService* service = TSAP_SERVICES.getServiceByEntity("ssap");
			cout << service->mangled() << endl;

		} catch (Poco::Exception& e)	{
			std::cerr << e.displayText() << std::endl;
		}
	}

#if 0
	<config>
Esempio n. 4
0
void SAXParserTest::testEncoding()
{
	SAXParser parser;
	Poco::Latin9Encoding encoding;
	parser.addEncoding("ISO-8859-15", &encoding); 
	
	std::istringstream istr(ENCODING);
	std::ostringstream ostr;
	XMLWriter writer(ostr, XMLWriter::WRITE_XML_DECLARATION, "ISO-8859-15", encoding);
	parser.setContentHandler(&writer);
	parser.setDTDHandler(&writer);
	parser.setProperty(XMLReader::PROPERTY_LEXICAL_HANDLER, static_cast<Poco::XML::LexicalHandler*>(&writer));
	InputSource source(istr);
	parser.parse(&source);
	
	std::string xml = ostr.str();
	assert (xml == ENCODING);
}
Esempio n. 5
0
void AreFriends::handleResponse(istream & inputstream) const
{
	SAXParser parser;
	parser.setFeature(XMLReader::FEATURE_NAMESPACES, true);
	parser.setFeature(XMLReader::FEATURE_NAMESPACE_PREFIXES, true);
	parser.setContentHandler(const_cast<AreFriends*>(this));
	
	try
	{
		SharedPtr<InputSource> inputSource(new InputSource(inputstream));
		parser.parse(inputSource);
		mSuccessCallback.call(mFriendInfoList);
	}
	catch (Exception& e)
	{
		cerr << e.displayText() << endl;
		mErrorCallback.call(ErrorResponse(0,e.message(), KeyValue()));
	}
}