/* * xml-hddm : tool that reads in a plain-text xml data document * and writes it out as a hddm (Hall D Data Model) * following the template provided. * * Version 1.2 - Richard Jones, December 2005. * - Updated code to use STL strings and vectors instead of old c-style * pre-allocated arrays and strXXX functions. * - Moved functions into classes grouped by function for better clarity. * - Introduced the XStream class library instead of the direct interface * to the rpc/xdr c-library function. This also gives access to a nice * integrated set of compression/decompression streambuf classes. * * Version 1.1 - Richard Jones, September 2003. * - Updated code to work with the new DOM-2 implementation Xerces-c * from apache.org. Significant changes have taken place in the API * since DOM-1. * - Added support for new types "long" (int64), "string" (char arrays of * arbitrary length), and "anyURI" (special case of string). * - Switched from native encoding to the use of the XDR library to make * hddm files machine-independent. * * Original version - Richard Jones, October 1 2001. * * * Programmer's Notes: * ------------------- * 1. The output from xml-hddm is a valid hddm data stream. * * 2. Two inputs are required: the input xml data document, and a xml * template describing the structure of the data in the document. * Both documents must be well-formed. In addition, the data document * must conform to the hddm specification document. Only if both of * these requirements are met is it possible to insure that the data * document can be expressed in a hddm stream. * * 3. The code has been tested with the xerces-c DOM implementation from * Apache, and is intended to be used with the xerces-c library. * * 4. Output is sent by default to stdout and can be changed with the * -o option. */ #include #include #include "XParsers.hpp" #include "XString.hpp" #include #include #include #include #include #include #include #include #include #include "particleType.h" using namespace xercesc; #define X(str) XString(str).unicode_str() #define S(str) str.c_str() int explicit_repeat_count = 1; class HDDMmaker { public: std::ostream* ofs; HDDMmaker() {}; ~HDDMmaker() {}; void constructDocument(DOMElement* el); void outputStream(DOMElement* thisEl, DOMElement* modelEl, std::ostream& ofs); }; void usage() { std::cerr << "\nUsage:\n" << " xml-hddm [-o ] -t