blob: eae1c27312dec3779feb189e297a3b2c2ee66f7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#include "transformHtml.h"
#include "logger.h"
#include <libxml++/document.h>
#include <libxslt/xsltutils.h>
#include <libxslt/transform.h>
class TransformXmlToHtml : public TransformImpl<xmlpp::Document, HtmlDocument> {
public:
void transform(const xmlpp::Document * cdata, HtmlDocument * result) const
{
xmlpp::Document * data = const_cast<xmlpp::Document *>(cdata);
typedef boost::shared_ptr<xsltStylesheet> XsltStyleSheetPtr;
XsltStyleSheetPtr cur = XsltStyleSheetPtr(xsltParseStylesheetFile(BAD_CAST stylesheet.c_str()), xsltFreeStylesheet);
if (!cur) {
throw xmlpp::exception("Failed to load stylesheet");
}
result->doc = xsltApplyStylesheet(cur.get(), data->cobj(), NULL);
if (!result) {
throw xmlpp::exception("Failed to perform transformation");
}
}
void configure(const xmlpp::Element * e)
{
stylesheet = e->get_attribute_value("style");
}
private:
Glib::ustring stylesheet;
};
DECLARE_TRANSFORM(TransformXmlToHtml)
|