From: Adam Dickmeiss Date: Mon, 25 Jul 2011 11:05:42 +0000 (+0200) Subject: zoom: use yaz_filepath_resolve for XSLT files. X-Git-Tag: v1.2.10~2 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=b484b17197842b9f282db212fce12ed44e2a2371;p=metaproxy-moved-to-github.git zoom: use yaz_filepath_resolve for XSLT files. Might as well use this function when it is also used for filter record_transform. Change the error handling a bit, for example do not even attempt to XML parse a non-existing file. --- diff --git a/src/filter_zoom.cpp b/src/filter_zoom.cpp index b3ddddb..e9fd0db 100644 --- a/src/filter_zoom.cpp +++ b/src/filter_zoom.cpp @@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "filter_zoom.hpp" #include #include +#include #include #include #include @@ -503,8 +504,6 @@ void yf::Zoom::Impl::configure(const xmlNode *ptr, bool test_only, if (path && *path) { file_path = path; - if (path[strlen(path)-1] != '/') - file_path += "/"; } for (ptr = ptr->children; ptr; ptr = ptr->next) { @@ -627,18 +626,35 @@ yf::Zoom::BackendPtr yf::Zoom::Frontend::get_backend_from_databases( xsltStylesheetPtr xsp = 0; if (sptr->transform_xsl_fname.length()) { + const char *path = 0; + + if (m_p->xsldir.length()) + path = m_p->xsldir.c_str(); + else + path = m_p->file_path.c_str(); std::string fname; - if (m_p->xsldir.length()) - fname = m_p->xsldir + "/" + sptr->transform_xsl_fname; + char fullpath[1024]; + char *cp = yaz_filepath_resolve(sptr->transform_xsl_fname.c_str(), + path, 0, fullpath); + if (cp) + fname.assign(cp); else - fname = m_p->file_path + sptr->transform_xsl_fname; + { + *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; + *addinfo = (char *) + odr_malloc(odr, 40 + sptr->transform_xsl_fname.length()); + sprintf(*addinfo, "File could not be read: %s", + sptr->transform_xsl_fname.c_str()); + BackendPtr b; + return b; + } xmlDoc *xsp_doc = xmlParseFile(fname.c_str()); if (!xsp_doc) { *error = YAZ_BIB1_TEMPORARY_SYSTEM_ERROR; - *addinfo = (char *) odr_malloc(odr, 40 + strlen(fname.c_str())); - sprintf(*addinfo, "xmlParseFile failed. File %s", fname.c_str()); + *addinfo = (char *) odr_malloc(odr, 40 + fname.length()); + sprintf(*addinfo, "xmlParseFile failed. File: %s", fname.c_str()); BackendPtr b; return b; }