From f0510d2f90467de8e8f260b47d79a9baaf9bef17 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 17 Sep 2009 07:15:29 +0200 Subject: Start tracking XSD with git --- examples/cxx/tree/streaming/driver.cxx | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 examples/cxx/tree/streaming/driver.cxx (limited to 'examples/cxx/tree/streaming/driver.cxx') diff --git a/examples/cxx/tree/streaming/driver.cxx b/examples/cxx/tree/streaming/driver.cxx new file mode 100644 index 0000000..6afc1ce --- /dev/null +++ b/examples/cxx/tree/streaming/driver.cxx @@ -0,0 +1,65 @@ +// file : examples/cxx/tree/streaming/driver.cxx +// author : Boris Kolpackov +// copyright : not copyrighted - public domain + +#include +#include + +#include "records.hxx" + +using std::cerr; +using std::endl; +using std::ios_base; + +int +main () +{ + try + { + std::ofstream ofs; + ofs.exceptions (ios_base::badbit | ios_base::failbit); + ofs.open ("out.xml"); + + // We will need to create XML declaration as well as open and close + // the root tag ourselves. + // + ofs << "" << endl + << "" << endl; + + // For performance reasons, we would like to initialize/terminate + // Xerces-C++ ourselves once instead of letting the serialization + // function do it for every record. + // + xercesc::XMLPlatformUtils::Initialize (); + + xml_schema::namespace_infomap map; + + for (unsigned long i (0); i < 1000; ++i) + { + // Create the next record. + // + record r ("data"); + + record_ (ofs, + r, + map, + "UTF-8", + xml_schema::flags::dont_initialize | + xml_schema::flags::no_xml_declaration); + } + + xercesc::XMLPlatformUtils::Terminate (); + + ofs << "" << endl; + } + catch (const xml_schema::exception& e) + { + cerr << e << endl; + return 1; + } + catch (const std::ios_base::failure&) + { + cerr << "io failure" << endl; + return 1; + } +} -- cgit v1.1