00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00033 #ifndef SP_GXML_XMLDUMP_HPP
00034 #define SP_GXML_XMLDUMP_HPP
00035 
00036 
00037 #include <string>
00038 
00039 
00040 #include <libxslt/xsltInternals.h>
00041 #include <libxml/parser.h>
00042 #include <libxml/xpath.h>
00043 #include <libxml/tree.h>
00044 #include <libxslt/transform.h>
00045 #include <libxslt/xsltutils.h>
00046 #include <libxslt/imports.h>
00047 
00048 
00049 #include <sp-gxmlcpp/Util.hpp>
00050 #include <sp-gxmlcpp/XMLTree.hpp>
00051 
00052 namespace SP
00053 {
00054 namespace GXML
00055 {
00056 
00057 
00058 class XSLTOutputBuf
00059 {
00060 public:
00061         enum Exceptions
00062         {
00063                 MEM_ERR,             
00064                 RESULT_INVALID,      
00065                 STYLE_INVALID        
00066         };
00067 
00068         XSLTOutputBuf(xmlDocPtr result, xsltStylesheetPtr style);
00069         ~XSLTOutputBuf();
00070         char * getAddr() const;
00071         int getSize() const;
00072 
00073 private:
00074         xmlCharEncodingHandlerPtr encoder_;
00075         xmlOutputBufferPtr buf_;
00076 };
00077 
00078 class XMLDump
00079 {
00080 public:
00081         enum Exceptions
00082         {
00083                 MEM_ERR,             
00084                 NODE_NOT_FOUND_ERR   
00085         };
00086 
00087         XMLDump(const xmlDocPtr doc, const xmlXPathContextPtr ctxt, const std::string & path="/");
00088         XMLDump(const XMLTree * tree, const std::string & path="/");
00089         XMLDump(const xmlDocPtr doc);
00090         
00091         XMLDump(const XSLTOutputBuf * buf);
00092 
00093         ~XMLDump();
00094 
00095         char * getAddr() const;
00096         std::string get() const;
00097         int getSize() const;
00098 
00099 private:
00100         xmlBufferPtr nodeDump_;           
00101         std::pair<xmlChar *, int> docDump_;    
00102         
00103         XSLTOutputBuf * xsltDump_;        
00104 
00105         
00106         void genDump(const xmlDocPtr doc, const xmlXPathContextPtr ctxt, const std::string & path);
00107 
00108         static char * nullString_;
00109 };
00110 
00111 }}
00112 #endif