# HG changeset patch # User František Kučera # Date 1547204685 -3600 # Node ID 1363ec0879caa2debcad429f0c8f93082a157d5f # Parent 4b566dee1a573ece2d6da37d182912bde6155366 report SAX events in a single relation diff -r 4b566dee1a57 -r 1363ec0879ca src/XMLCommand.h --- a/src/XMLCommand.h Fri Jan 11 01:13:40 2019 +0100 +++ b/src/XMLCommand.h Fri Jan 11 12:04:45 2019 +0100 @@ -51,32 +51,33 @@ RelpipeSaxHandler(std::ostream& output) : DefaultHandler(), writer(Factory::create(output)) { } - void startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname, const Attributes& attrs) override { + void startDocument() override { //XMLString:: // TODO: remove demo - writer->startRelation(L"xml_startElement",{ - {L"s", TypeId::STRING}, + writer->startRelation(L"xml",{ + {L"event", TypeId::STRING}, + {L"data", TypeId::STRING}, }, true); + } - writer->writeAttribute(L"a"); + void startElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname, const Attributes& attrs) override { + writer->writeAttribute(L"startElement"); + writer->writeAttribute(L""); } void endElement(const XMLCh * const uri, const XMLCh * const localname, const XMLCh * const qname) override { - // TODO: remove demo - writer->startRelation(L"xml_endElement",{ - {L"s", TypeId::STRING}, - }, true); + writer->writeAttribute(L"endElement"); + writer->writeAttribute(L""); + } - writer->writeAttribute(L"a"); + void characters(const XMLCh * const chars, const XMLSize_t length) override { + writer->writeAttribute(L"characters"); + writer->writeAttribute(to_wstring(length)); } void endDocument() override { - // TODO: remove demo - writer->startRelation(L"xml_endDocument",{ - {L"s", TypeId::STRING}, - }, true); - - writer->writeAttribute(L"a"); + writer->writeAttribute(L"endDocument"); + writer->writeAttribute(L""); } }; diff -r 4b566dee1a57 -r 1363ec0879ca src/relpipe-in-xml.cpp --- a/src/relpipe-in-xml.cpp Fri Jan 11 01:13:40 2019 +0100 +++ b/src/relpipe-in-xml.cpp Fri Jan 11 12:04:45 2019 +0100 @@ -56,6 +56,12 @@ fwprintf(stderr, L"Caught xercesc::XMLException\n"); fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; + } catch (const xercesc::SAXParseException& e) { + // TODO: print message + // char* message = xercesc::XMLString::transcode(e.getMessage()); + fwprintf(stderr, L"Caught xercesc::SAXParseException\n"); + fwprintf(stderr, L"Debug: Input stream: eof=%ls, lastRead=%d\n", (cin.eof() ? L"true" : L"false"), cin.gcount()); + resultCode = CLI::EXIT_CODE_UNEXPECTED_ERROR; } return resultCode;