28 #include <xercesc/sax2/DefaultHandler.hpp> |
28 #include <xercesc/sax2/DefaultHandler.hpp> |
29 #include <xercesc/util/XMLString.hpp> |
29 #include <xercesc/util/XMLString.hpp> |
30 |
30 |
31 #include <relpipe/writer/typedefs.h> |
31 #include <relpipe/writer/typedefs.h> |
32 |
32 |
|
33 #include "StreamInputSource.h" |
|
34 |
33 namespace relpipe { |
35 namespace relpipe { |
34 namespace in { |
36 namespace in { |
35 namespace xml { |
37 namespace xml { |
36 |
38 |
37 class XMLCommand { |
39 class XMLCommand { |
38 public: |
40 public: |
39 |
41 |
40 void process(std::istream& input, std::ostream& output) { |
42 void process(std::istream& input, std::ostream& output) { |
41 using namespace relpipe::writer; |
43 using namespace relpipe::writer; |
42 using namespace xercesc; |
44 using namespace xercesc; |
43 std::shared_ptr<RelationalWriter> writer(Factory::create(output)); |
45 unique_ptr<RelationalWriter> writer(Factory::create(output)); |
|
46 XMLPlatformUtils::Initialize(); |
|
47 |
|
48 |
|
49 unique_ptr<SAX2XMLReader> parser(XMLReaderFactory::createXMLReader()); |
|
50 parser->setFeature(XMLUni::fgSAX2CoreValidation, true); |
|
51 parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); |
|
52 |
|
53 // TODO: custom handler that reads |
|
54 DefaultHandler defaultHandler; |
|
55 parser->setContentHandler(&defaultHandler); |
|
56 parser->setErrorHandler(&defaultHandler); |
|
57 |
|
58 StreamInputSource inputSource(input); |
|
59 |
|
60 parser->parse(inputSource); |
|
61 |
44 |
62 |
45 // TODO: remove demo |
63 // TODO: remove demo |
46 // Various data types passed as strings |
64 // Various data types passed as strings |
47 writer->startRelation(L"xml",{ |
65 writer->startRelation(L"xml",{ |
48 {L"s", TypeId::STRING}, |
66 {L"s", TypeId::STRING}, |