/** * Extrae la cadena original del comprobante fiscal * * La funcion regresa: * * 0 En caso de generar la cadena original exitosamente, * * y en caso de error: * * 1 Cuando la stylsheet, proporcionada para generar la cadena * original no pudo ser compilada. * 2 Cuando las transformaciones, definidas en la stylesheet * indicada no pudieron aplicarse al CFDi. * 3 No fue posible escribir la cadena original a un buffer * */ int genera_cadena_original(const char *stylesheet, xmlDocPtr doc, xmlChar** cadena, int verbose) { xsltStylesheetPtr style = NULL; xmlDocPtr result = NULL; int cadena_len = 0; int out = 0; xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; xsltSetGenericErrorFunc(stderr, local_error_function); style = xsltParseStylesheetFile((const xmlChar *)stylesheet); if ( style == NULL ) { if ( verbose ) { fprintf(stderr, "%s:%d Ocurrio un Error. Stylesheet (%s) no analizada.\n", __FILE__, __LINE__, stylesheet); } xsltCleanupGlobals(); return 1; } result = xsltApplyStylesheet(style, doc, NULL); if ( result == NULL ) { if ( verbose ) { fprintf(stderr, "%s:%d Ocurrio un Error. Transformaciones de stylesheet (%s) no aplicadas.\n", __FILE__, __LINE__, stylesheet); } xsltFreeStylesheet(style); xsltCleanupGlobals(); return 2; } out = xsltSaveResultToString(cadena, &cadena_len, result, style); if ( out == -1 ) { if ( verbose ) { fprintf(stderr, "%s:%d Ocurrio un error. Error al salvar la cadena original en el buffer.\n", __FILE__, __LINE__); } return 3; } xsltFreeStylesheet(style); xmlFreeDoc(result); if ( verbose ) { printf("%s:%d Cadena original de la información del comprobante:\n%s\n", __FILE__, __LINE__, *cadena); } xsltCleanupGlobals(); return 0; }
ReturnCode xsltTransformToFile(xmlDocPtr doc, const char *xslFilename, const char *outputFilename) { xmlDocPtr res; xsltStylesheetPtr style; if( (xslFilename == NULL) || (outputFilename == NULL) ) { printMsg(MESSAGETYPE_ERROR, "xsltTransformToFile: Null pointer error"); return FAILED; } style = xsltParseStylesheetFile ((const xmlChar *) xslFilename); if (style == NULL) { printMsg(MESSAGETYPE_ERROR, "xsltTransformToFile: Could not parse XSLT file: %s", xslFilename); return FAILED; } res = xsltApplyStylesheet(style, doc, NULL); if(res == NULL){ printMsg(MESSAGETYPE_ERROR, "xsltTransformToFile: Problem applying stylesheet"); return FAILED; } xsltSaveResultToFilename(outputFilename, res, style, 0); xmlFreeDoc(res); xsltFreeStylesheet(style); return SUCCESS; }
int main(int argc, char **argv) { xsltStylesheetPtr stylesheet = NULL; xmlDocPtr doc, res; char* stylesheetfile; char* infile; char *outfile; if (argc!=4) { printf("XSLT Transform\n2009 by thom using libxml2\nUsage:\n\txslt-transform <stylesheet> <infile> <outfile>\n"); exit(1); } stylesheetfile = argv[1]; infile = argv[2]; outfile = argv[3]; xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; stylesheet = xsltParseStylesheetFile(BAD_CAST stylesheetfile); doc = xmlParseFile(infile); res = xsltApplyStylesheet(stylesheet, doc, 0); printf("use \"%s\" to transform \"%s\" to \"%s\" ...\n", stylesheetfile, infile, outfile); xsltSaveResultToFilename(outfile, res, stylesheet, 0); xsltFreeStylesheet(stylesheet); xmlFreeDoc(res); xmlFreeDoc(doc); xsltCleanupGlobals(); xmlCleanupParser(); printf("\tDone.\n"); exit(0); }
int main( int argc, char *argv[] ) { if( argc != 3 ) { std::cerr << "usage: testlibxslt1 <XSLT file> <XML file>" << std::endl; return 1; } LIBXML_TEST_VERSION xsltStylesheetPtr script = xsltParseStylesheetFile( ( const xmlChar *)argv[1] ); xmlDocPtr doc = xmlParseFile( argv[2] ); const char *params[1] = { NULL }; xmlDocPtr res = xsltApplyStylesheet( script, doc, params ); xmlChar *resTxt; int resLen; xsltSaveResultToString( &resTxt, &resLen, res, script ); std::cout << resTxt; xmlFreeDoc( res ); xmlFreeDoc( doc ); xsltFreeStylesheet( script ); xsltCleanupGlobals( ); xmlCleanupParser( ); return 0; }
static xmlDoc *test_xslt_transforms(xmlDoc *doc, GError **error) { struct xslt_files *info = xslt_files; xmlDoc *transformed; xsltStylesheetPtr xslt = NULL; xmlNode *root_element = xmlDocGetRootElement(doc); char *attribute; while ((info->root) && (strcasecmp(root_element->name, info->root) != 0)) { info++; } if (info->root) { attribute = xmlGetProp(xmlFirstElementChild(root_element), "name"); if (attribute) { if (strcasecmp(attribute, "subsurface") == 0) { free((void *)attribute); return doc; } free((void *)attribute); } xmlSubstituteEntitiesDefault(1); xslt = get_stylesheet(info->file); if (xslt == NULL) { parser_error(error, _("Can't open stylesheet (%s)/%s"), xslt_path, info->file); return doc; } transformed = xsltApplyStylesheet(xslt, doc, NULL); xmlFreeDoc(doc); xsltFreeStylesheet(xslt); return transformed; } return doc; }
DocumentImpl* XSLTProcessorImpl::transformDocument(DocumentImpl* doc) { // FIXME: Right now we assume |doc| is unparsed, but if it has been parsed we will need to serialize it // and then feed that resulting source to libxslt. m_resultOutput = ""; if (!m_stylesheet || !m_stylesheet->document()) return 0; globalSheet = m_stylesheet; xsltSetLoaderFunc(stylesheetLoadFunc); xsltStylesheetPtr sheet = m_stylesheet->compileStyleSheet(); globalSheet = 0; xsltSetLoaderFunc(0); if (!sheet) return 0; m_stylesheet->clearDocuments(); // Get the parsed source document. xmlDocPtr sourceDoc = (xmlDocPtr)doc->transformSource(); xmlDocPtr resultDoc = xsltApplyStylesheet(sheet, sourceDoc, NULL); DocumentImpl* result = documentFromXMLDocPtr(resultDoc, sheet); xsltFreeStylesheet(sheet); return result; }
/* {{{ xsl_objects_free_storage */ void xsl_objects_free_storage(zend_object *object) { xsl_object *intern = php_xsl_fetch_object(object); zend_object_std_dtor(&intern->std); zend_hash_destroy(intern->parameter); FREE_HASHTABLE(intern->parameter); zend_hash_destroy(intern->registered_phpfunctions); FREE_HASHTABLE(intern->registered_phpfunctions); if (intern->node_list) { zend_hash_destroy(intern->node_list); FREE_HASHTABLE(intern->node_list); } if (intern->doc) { php_libxml_decrement_doc_ref(intern->doc); efree(intern->doc); } if (intern->ptr) { /* free wrapper */ if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) { ((xsltStylesheetPtr) intern->ptr)->_private = NULL; } xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr); intern->ptr = NULL; } if (intern->profiling) { efree(intern->profiling); } }
void Docbook2XhtmlGeneratorJob::run() { UMLDoc* umlDoc = UMLApp::app()->document(); xsltStylesheetPtr cur = NULL; xmlDocPtr doc, res; const char *params[16 + 1]; int nbparams = 0; params[nbparams] = NULL; umlDoc->writeToStatusBar(i18n("Exporting to XHTML...")); QString xsltFileName(KGlobal::dirs()->findResource("appdata", QLatin1String("docbook2xhtml.xsl"))); uDebug() << "XSLT file is'" << xsltFileName << "'"; QFile xsltFile(xsltFileName); xsltFile.open(QIODevice::ReadOnly); QString xslt = QString::fromLatin1(xsltFile.readAll()); uDebug() << "XSLT is'" << xslt << "'"; xsltFile.close(); QString localXsl = KGlobal::dirs()->findResource("data", QLatin1String("ksgmltools2/docbook/xsl/html/docbook.xsl")); uDebug() << "Local xsl is'" << localXsl << "'"; if (!localXsl.isEmpty()) { localXsl = QLatin1String("href=\"file://") + localXsl + QLatin1String("\""); xslt.replace(QRegExp(QLatin1String("href=\"http://[^\"]*\"")), localXsl); } KTemporaryFile tmpXsl; tmpXsl.setAutoRemove(false); tmpXsl.open(); QTextStream str (&tmpXsl); str << xslt; str.flush(); xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; uDebug() << "Parsing stylesheet " << tmpXsl.fileName(); cur = xsltParseStylesheetFile((const xmlChar *)tmpXsl.fileName().toLatin1().constData()); uDebug() << "Parsing file " << m_docbookUrl.path(); doc = xmlParseFile((const char*)(m_docbookUrl.path().toUtf8())); uDebug() << "Applying stylesheet "; res = xsltApplyStylesheet(cur, doc, params); KTemporaryFile tmpXhtml; tmpXhtml.setAutoRemove(false); tmpXhtml.open(); uDebug() << "Writing HTML result to temp file: " << tmpXhtml.fileName(); xsltSaveResultToFd(tmpXhtml.handle(), res, cur); xsltFreeStylesheet(cur); xmlFreeDoc(res); xmlFreeDoc(doc); xsltCleanupGlobals(); xmlCleanupParser(); emit xhtmlGenerated(tmpXhtml.fileName()); }
void clish_xslt_release(clish_xslt_t *stylesheet) { xsltStylesheet* cur = xslt_to_xsltStylesheet(stylesheet); if (!cur) return; xsltFreeStylesheet(cur); }
void XSLT::unload(Inkscape::Extension::Extension *module) { if (!module->loaded()) { return; } xsltFreeStylesheet(_stylesheet); // No need to use xmlfreedoc(_parsedDoc), it's handled by xsltFreeStylesheet(_stylesheet); return; }
void ExportDialog::accept() { QDialog::accept(); if (ui->csvRadio->isChecked()) { /// Find the CSV filter in the standard filter list //[email protected]: good and clean solution QStringList defaultFilters = KEduVocDocument::pattern(KEduVocDocument::Writing).split('\n'); QString filter = defaultFilters.filter(QStringLiteral("csv")).join(QStringLiteral("\n")); QUrl filename = getFileName(filter); if (filename != QUrl()) { m_doc->saveAs(filename); } return; } QString xslFile; if (ui->flashCardRadio->isChecked()) { xslFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("parley/xslt/flashcards.xsl")); } else { xslFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("parley/xslt/table.xsl")); } QString filter = "*.html|" + i18n("HTML document"); QUrl filename = getFileName(filter); if (filename.isEmpty()) { return; } qDebug() << "XSLT starting"; xsltStylesheetPtr cur = NULL; xmlDocPtr doc, res; xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; cur = xsltParseStylesheetFile((const xmlChar*) xslFile.toLatin1().constData()); doc = xmlParseDoc((const xmlChar*) m_doc->document()->toByteArray(m_doc->document()->generator()).constData()); res = xsltApplyStylesheet(cur, doc, 0); FILE* result = fopen(QFile::encodeName(filename.toLocalFile()).constData(), "w"); if (result != NULL) { xsltSaveResultToFile(result, res, cur); fclose(result); } else { KMessageBox::error(this, i18n("Could not write to file \"%1\"", filename.toLocalFile())); } xsltFreeStylesheet(cur); xmlFreeDoc(res); xmlFreeDoc(doc); xsltCleanupGlobals(); xmlCleanupParser(); qDebug() << "XSLT finished"; }
bool XSLTProcessor::transformToString(Node* sourceNode, String& mimeType, String& resultString, String& resultEncoding) { RefPtr<Document> ownerDocument = sourceNode->document(); setXSLTLoadCallBack(docLoaderFunc, this, ownerDocument->docLoader()); xsltStylesheetPtr sheet = xsltStylesheetPointer(m_stylesheet, m_stylesheetRootNode.get()); if (!sheet) { setXSLTLoadCallBack(0, 0, 0); return false; } m_stylesheet->clearDocuments(); xmlChar* origMethod = sheet->method; if (!origMethod && mimeType == "text/html") sheet->method = (xmlChar*)"html"; bool success = false; bool shouldFreeSourceDoc = false; if (xmlDocPtr sourceDoc = xmlDocPtrFromNode(sourceNode, shouldFreeSourceDoc)) { // The XML declaration would prevent parsing the result as a fragment, and it's not needed even for documents, // as the result of this function is always immediately parsed. sheet->omitXmlDeclaration = true; xsltTransformContextPtr transformContext = xsltNewTransformContext(sheet, sourceDoc); registerXSLTExtensions(transformContext); // <http://bugs.webkit.org/show_bug.cgi?id=16077>: XSLT processor <xsl:sort> algorithm only compares by code point. xsltSetCtxtSortFunc(transformContext, xsltUnicodeSortFunction); // This is a workaround for a bug in libxslt. // The bug has been fixed in version 1.1.13, so once we ship that this can be removed. if (!transformContext->globalVars) transformContext->globalVars = xmlHashCreate(20); const char** params = xsltParamArrayFromParameterMap(m_parameters); xsltQuoteUserParams(transformContext, params); xmlDocPtr resultDoc = xsltApplyStylesheetUser(sheet, sourceDoc, 0, 0, 0, transformContext); xsltFreeTransformContext(transformContext); freeXsltParamArray(params); if (shouldFreeSourceDoc) xmlFreeDoc(sourceDoc); if ((success = saveResultToString(resultDoc, sheet, resultString))) { mimeType = resultMIMEType(resultDoc, sheet); resultEncoding = (char*)resultDoc->encoding; } xmlFreeDoc(resultDoc); } sheet->method = origMethod; setXSLTLoadCallBack(0, 0, 0); xsltFreeStylesheet(sheet); m_stylesheet = 0; return success; }
int export_dives_xslt(const char *filename, const bool selected, const int units, const char *export_xslt) { FILE *f; struct membuffer buf = { 0 }; xmlDoc *doc; xsltStylesheetPtr xslt = NULL; xmlDoc *transformed; int res = 0; char *params[3]; int pnr = 0; char unitstr[3]; if (verbose) fprintf(stderr, "export_dives_xslt with stylesheet %s\n", export_xslt); if (!filename) return report_error("No filename for export"); /* Save XML to file and convert it into a memory buffer */ save_dives_buffer(&buf, selected); /* * Parse the memory buffer into XML document and * transform it to selected export format, finally dumping * the XML into a character buffer. */ doc = xmlReadMemory(buf.buffer, buf.len, "divelog", NULL, 0); free_buffer(&buf); if (!doc) return report_error("Failed to read XML memory"); /* Convert to export format */ xslt = get_stylesheet(export_xslt); if (!xslt) return report_error("Failed to open export conversion stylesheet"); snprintf(unitstr, 3, "%d", units); params[pnr++] = "units"; params[pnr++] = unitstr; params[pnr++] = NULL; transformed = xsltApplyStylesheet(xslt, doc, (const char **)params); xmlFreeDoc(doc); /* Write the transformed export to file */ f = subsurface_fopen(filename, "w"); if (f) { xsltSaveResultToFile(f, transformed, xslt); fclose(f); /* Check write errors? */ } else { res = report_error("Failed to open %s for writing (%s)", filename, strerror(errno)); } xsltFreeStylesheet(xslt); xmlFreeDoc(transformed); return res; }
static void free_xslt_info( struct xslt_info *info ) { if (info->pattern) xsltFreeCompMatchList( info->pattern ); if (info->sheet) xsltFreeStylesheet( info->sheet ); if (info->ctxt) xsltFreeTransformContext( info->ctxt ); }
XSLTUtils::~XSLTUtils() { if (m_xmlInput) xmlFreeDoc(m_xmlInput); if (m_xmlOutput) xmlFreeDoc(m_xmlOutput); if (m_xsltStylesheet) xsltFreeStylesheet(m_xsltStylesheet); }
static gchar * update_apply_xslt (updateJobPtr job) { xsltStylesheetPtr xslt = NULL; xmlOutputBufferPtr buf; xmlDocPtr srcDoc = NULL, resDoc = NULL; gchar *output = NULL; g_assert (NULL != job->result); do { srcDoc = xml_parse (job->result->data, job->result->size, NULL); if (!srcDoc) { g_warning("fatal: parsing request result XML source failed (%s)!", job->request->filtercmd); break; } /* load localization stylesheet */ xslt = xsltParseStylesheetFile (job->request->filtercmd); if (!xslt) { g_warning ("fatal: could not load filter stylesheet \"%s\"!", job->request->filtercmd); break; } resDoc = xsltApplyStylesheet (xslt, srcDoc, NULL); if (!resDoc) { g_warning ("fatal: applying stylesheet \"%s\" failed!", job->request->filtercmd); break; } buf = xmlAllocOutputBuffer (NULL); if (-1 == xsltSaveResultTo (buf, resDoc, xslt)) { g_warning ("fatal: retrieving result of filter stylesheet failed (%s)!", job->request->filtercmd); break; } #ifdef LIBXML2_NEW_BUFFER if (xmlOutputBufferGetSize (buf) > 0) output = xmlCharStrdup (xmlOutputBufferGetContent (buf)); #else if (xmlBufferLength (buf->buffer) > 0) output = xmlCharStrdup (xmlBufferContent (buf->buffer)); #endif xmlOutputBufferClose (buf); } while (FALSE); if (srcDoc) xmlFreeDoc (srcDoc); if (resDoc) xmlFreeDoc (resDoc); if (xslt) xsltFreeStylesheet (xslt); return output; }
static void dealloc(nokogiriXsltStylesheetTuple *wrapper) { xsltStylesheetPtr doc = wrapper->ss; NOKOGIRI_DEBUG_START(doc); xsltFreeStylesheet(doc); /* commented out for now. */ NOKOGIRI_DEBUG_END(doc); free(wrapper); }
xsltStylesheet_auto_ptr& operator=(const xsltStylesheet_auto_ptr& _Y) {if (this != &_Y) {if (_Ptr != _Y.get()) {if (_Owns && _Ptr) xsltFreeStylesheet(_Ptr); _Owns = _Y._Owns; } else if (_Y._Owns) _Owns = true; _Ptr = _Y.release(); } return (*this); }
/********************************************************************** print_xml_filename_to_filename_using_stylesheet Print the contents of an XML file to another file applying an XSLT stylesheet. Returns TRUE if successful, FALSE otherwise. **********************************************************************/ BOOLEAN_T print_xml_filename_to_filename_using_stylesheet( char* input_file_path, /* path to XML input file IN */ char* stylesheet_file_path, /* path to MEME XSL stylesheet IN */ char* output_file_path /* path to HTML output file IN */ ) { xsltStylesheetPtr stylesheet = NULL; xmlDocPtr input_doc = NULL; xmlDocPtr output_doc = NULL; const int PERFORM_ENTITY_SUBST = 1; xmlSubstituteEntitiesDefault(PERFORM_ENTITY_SUBST); xmlLoadExtDtdDefaultValue = 0; exsltRegisterAll(); stylesheet = xsltParseStylesheetFile((const xmlChar *) stylesheet_file_path); if (!stylesheet) { fprintf(stderr, "Unable to parse stylesheet %s.\n", stylesheet_file_path); return FALSE; } input_doc = xmlParseFile(input_file_path); if (!input_doc) { fprintf(stderr, "Unable to parse input file %s.\n", input_file_path); return FALSE; } output_doc = xsltApplyStylesheet(stylesheet, input_doc, NULL); if (!output_doc) { fprintf( stderr, "Unable to apply stylsheet %s to input from file %s.\n", stylesheet_file_path, input_file_path ); return FALSE; } int result = xsltSaveResultToFilename(output_file_path, output_doc, stylesheet, 0); if (result == -1) { fprintf( stderr, "Unable to save result of applying stylesheet %s to %s.\n", stylesheet_file_path, output_file_path ); } xsltFreeStylesheet(stylesheet); xmlFreeDoc(output_doc); xmlFreeDoc(input_doc); xsltCleanupGlobals(); xmlCleanupParser(); return TRUE; } /* print_xml_file_html */
void c_XSLTProcessor::sweep() { if (m_stylesheet) { xsltFreeStylesheet(m_stylesheet); m_stylesheet = nullptr; } if (m_doc) { xmlFreeDoc(m_doc); m_doc = nullptr; } }
/** * Destroys this xml stylesheet * @param xsl The xml stylesheet * @return nothing */ void exml_xsl_destroy( EXML_XSL *xsl ) { CHECK_PARAM_POINTER("xsl", xsl); if( xsl->buffers ) ecore_list_destroy(xsl->buffers); if( xsl->cur ) xsltFreeStylesheet(xsl->cur); free(xsl); }
static xsltStylesheetPtr render_load_stylesheet (const gchar *xsltName) { xsltStylesheetPtr i18n_filter; xsltStylesheetPtr xslt; xmlDocPtr xsltDoc, resDoc; gchar *filename; if (!stylesheets) render_init (); /* try to serve the stylesheet from the cache */ xslt = (xsltStylesheetPtr)g_hash_table_lookup (stylesheets, xsltName); if (xslt) return xslt; /* or load and translate it... */ /* 1. load localization stylesheet */ i18n_filter = xsltParseStylesheetFile (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "xslt" G_DIR_SEPARATOR_S "i18n-filter.xslt"); if (!i18n_filter) { g_warning ("fatal: could not load localization stylesheet!"); return NULL; } /* 2. load and localize the rendering stylesheet */ filename = g_strjoin (NULL, PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "xslt" G_DIR_SEPARATOR_S, xsltName, ".xml", NULL); xsltDoc = xmlParseFile (filename); if (!xsltDoc) g_warning ("fatal: could not load rendering stylesheet (%s)!", xsltName); g_free (filename); resDoc = xsltApplyStylesheet (i18n_filter, xsltDoc, (const gchar **)langParams->params); if (!resDoc) g_warning ("fatal: applying localization stylesheet failed (%s)!", xsltName); /* Use the following to debug XSLT transformation problems */ /* xsltSaveResultToFile (stdout, resDoc, i18n_filter); */ /* 3. create localized rendering stylesheet */ xslt = xsltParseStylesheetDoc(resDoc); if (!xslt) g_warning("fatal: could not load rendering stylesheet (%s)!", xsltName); xmlFreeDoc (xsltDoc); xsltFreeStylesheet (i18n_filter); g_hash_table_insert (stylesheets, g_strdup (xsltName), xslt); return xslt; }
static int convert_xslt(void *vinfo, WRBUF record, WRBUF wr_error) { int ret = 0; struct xslt_info *info = vinfo; xmlDocPtr doc = xmlParseMemory(wrbuf_buf(record), wrbuf_len(record)); if (!doc) { wrbuf_printf(wr_error, "xmlParseMemory failed"); ret = -1; } else { xmlDocPtr xsp_doc = xmlCopyDoc(info->xsp_doc, 1); xsltStylesheetPtr xsp = xsltParseStylesheetDoc(xsp_doc); xmlDocPtr res = xsltApplyStylesheet(xsp, doc, info->xsl_parms); if (res) { xmlChar *out_buf = 0; int out_len; #if HAVE_XSLTSAVERESULTTOSTRING xsltSaveResultToString(&out_buf, &out_len, res, xsp); #else xmlDocDumpFormatMemory (res, &out_buf, &out_len, 1); #endif if (!out_buf) { wrbuf_printf(wr_error, "xsltSaveResultToString failed"); ret = -1; } else { wrbuf_rewind(record); wrbuf_write(record, (const char *) out_buf, out_len); xmlFree(out_buf); } xmlFreeDoc(res); } else { wrbuf_printf(wr_error, "xsltApplyStylesheet failed"); ret = -1; } xmlFreeDoc(doc); xsltFreeStylesheet(xsp); /* frees xsp_doc too */ } return ret; }
void transform(fs::path xslt, std::string inputfile, std::string outputfile) { auto stylesheet = xsltParseStylesheetFile(BAD_CAST xslt.c_str()); auto doc = xmlParseFile(inputfile.c_str()); const char *params = NULL; auto result = xsltApplyStylesheet(stylesheet, doc, ¶ms); xsltSaveResultToFilename(outputfile.c_str(), result, stylesheet, 0); xmlFreeDoc(doc); xmlFreeDoc(result); xsltFreeStylesheet(stylesheet); }
void xslt_shutdown() { int i; for(i=0; i < CACHESIZE; i++) { if(cache[i].filename) free(cache[i].filename); if(cache[i].stylesheet) xsltFreeStylesheet(cache[i].stylesheet); } thread_mutex_destroy (&xsltlock); xsltCleanupGlobals(); }
/** * Clean up memory */ void CXSLTransform::Reset() { // Also frees xsl in SetXSLDoc() if (m_Style) { xsltFreeStylesheet(m_Style); m_Style = NULL; } if (m_Result) { xmlFreeDoc(m_Result); m_Result = NULL; } m_LastError.Empty(); }
/*Free - frees xml document*/ void CXMLDocument::Free() { if (!isinited()) return; xmlFreeDoc(doc); doc = NULL; if (NULL != xpathContext) xmlXPathFreeContext(xpathContext); xpathContext = NULL; // MDW-2013-09-04: [[ RevXmlXslt ]] if (NULL != xsltID) xsltFreeStylesheet(xsltID); xsltID = NULL; }
void normalize_record_destroy(normalize_record_t nt) { if (nt) { struct normalize_step *m; for (m = nt->steps; m; m = m->next) { if (m->stylesheet) xsltFreeStylesheet(m->stylesheet); } nmem_destroy(nt->nmem); } }
cepgdata2xmltv::~cepgdata2xmltv () { if (pxsltStylesheet) { xsltFreeStylesheet(pxsltStylesheet); xsltCleanupGlobals(); xmlCleanupParser(); } if (dtdmem) { free(dtdmem); dtdmem=NULL; } }
static int evict_cache_entry(void) { int i, age=0, oldest=0; for(i=0; i < CACHESIZE; i++) { if(cache[i].cache_age > age) { age = cache[i].cache_age; oldest = i; } } xsltFreeStylesheet(cache[oldest].stylesheet); free(cache[oldest].filename); return oldest; }