From 64826d5da49fe75c99ed77eb8f7ed388bc7bb56a Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 9 Jan 2013 20:30:35 +0000 Subject: Add transform code to default error stage Do xslt transform according to PI, not source value --- project2/cgi/cgiStageDefaultError.cpp | 6 ++++++ project2/xml/transformHtml.cpp | 8 +------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/project2/cgi/cgiStageDefaultError.cpp b/project2/cgi/cgiStageDefaultError.cpp index c5642d5..b8f0b4b 100644 --- a/project2/cgi/cgiStageDefaultError.cpp +++ b/project2/cgi/cgiStageDefaultError.cpp @@ -13,6 +13,12 @@ CgiApplicationEngine::DefaultErrorStage::DefaultErrorStage(const std::exception what(ex.what()), pres(new XmlPresenter(DefaultErrorStageResp, env()->errorTransformStyle, env()->errorContentType)) { + auto xp = dynamic_cast(pres.get()); + auto cp = dynamic_cast(pres.get()); + if (xp && cp && cp->contentType == this->env()->transformContentType) { + auto h = TransformTargetLoader::getFor(this->env()->transformTargetType)->create(root, Default); + xp->addTarget(h, root); + } } CgiApplicationEngine::DefaultErrorStage::~DefaultErrorStage() diff --git a/project2/xml/transformHtml.cpp b/project2/xml/transformHtml.cpp index 0348c87..f6a0431 100644 --- a/project2/xml/transformHtml.cpp +++ b/project2/xml/transformHtml.cpp @@ -59,7 +59,7 @@ class TransformXmlToHtml : public TransformImpl { { xmlpp::Document * data = const_cast(cdata); typedef boost::shared_ptr XsltStyleSheetPtr; - XsltStyleSheetPtr cur = XsltStyleSheetPtr(xsltParseStylesheetFile(BAD_CAST stylesheet.c_str()), xsltFreeStylesheet); + XsltStyleSheetPtr cur = XsltStyleSheetPtr(xsltLoadStylesheetPI(data->cobj()), xsltFreeStylesheet); if (!cur) { throw xmlpp::exception("Failed to load stylesheet"); } @@ -73,12 +73,6 @@ class TransformXmlToHtml : public TransformImpl { } result->contentType = (char*)(cur.get()->mediaType); } - void configure(ScriptNodePtr e) - { - stylesheet = e->value("style").as(); - } - private: - Glib::ustring stylesheet; }; class XmlTransformLoader : public TransformLoader::For { -- cgit v1.2.3