00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00031 #ifndef SP_GXML_XSLTRANS_HPP
00032 #define SP_GXML_XSLTRANS_HPP
00033 
00034 
00035 #include <string>
00036 
00037 
00038 #include <sp-gxmlcpp/XMLDump.hpp>
00039 #include <sp-gxmlcpp/XMLTree.hpp>
00040 
00041 
00042 #include <libxml/xpath.h>
00043 #include <libxml/tree.h>
00044 #include <libxslt/xsltInternals.h>
00045 
00046 namespace SP {
00047 namespace GXML {
00048 
00049 class XSLTrans
00050 {
00051 public:
00052         enum Exceptions
00053         {
00054                 PARSE_ERR=1,  
00055                 STYLE_ERR,    
00056                 TRANS_ERR     
00057         };
00058 
00059         XSLTrans(const char * xmlBuffer, int size=-1, const std::string & baseURI="");
00060         XSLTrans(const std::string & xmlString, const std::string & baseURI="");
00061         XSLTrans(std::ifstream & f, const std::string & baseURI="");
00062 
00063         ~XSLTrans();
00064 
00065         xsltStylesheetPtr getStylesheetPtr();
00066 
00067         
00068         std::auto_ptr<XMLTree> transToXMLTree(const xmlDocPtr doc) const;
00069 
00070         std::auto_ptr<XMLDump> trans(const xmlDocPtr doc) const;
00071         std::auto_ptr<XMLDump> trans(const XMLTree * xmlTree) const;
00072         std::auto_ptr<XMLDump> trans(const std::string & xmlString) const;
00073 
00074 private:
00075         xmlDocPtr doc_;
00076         xsltStylesheetPtr style_;
00077 
00078         void genTrans(const char * xmlBuffer, int size=-1, const std::string & baseURI="");
00079 
00080         static char * defaultEncoding_;
00081 };
00082 
00083 }}
00084 #endif