コード例 #1
0
/**
 * 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;
}
コード例 #2
0
ファイル: testlibxslt1.cpp プロジェクト: ProjectTegano/Tegano
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;
}
コード例 #3
0
ファイル: exml.c プロジェクト: playya/Enlightenment
/**
 * Write the transformed xml document out to a file descriptor.
 * @param   xml The xml document
 * @param  xsl The xml stylesheet
 * @param  params The transform parameters
 * @param   fd The source xml input descriptor
 * @return	@c TRUE if successful, @c FALSE if an error occurs.
 * @ingroup EXML_XSLT_Group
 */
int exml_transform_fd_write( EXML *xml, EXML_XSL *xsl, const char *params[],
                             int fd )
{
	int ret;
	xmlDocPtr res, doc;

	CHECK_PARAM_POINTER_RETURN("xml", xml, FALSE);
	CHECK_PARAM_POINTER_RETURN("xsl", xsl, FALSE);
	
	exml_doc_write(xml, &doc);

	res = xsltApplyStylesheet(xsl->cur, doc, params);

	xmlFreeDoc(doc);

	if( !res ) {
		return FALSE;
	}

	ret = xsltSaveResultToFd(fd, res, xsl->cur);

	xmlFreeDoc(res);

	xsltCleanupGlobals();

	if( ret < 0 )
		return FALSE;

	return TRUE;
}
コード例 #4
0
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
    switch(fdwReason)
    {
    case DLL_PROCESS_ATTACH:
#ifdef HAVE_LIBXML2
        xmlInitParser();
#endif
#ifdef HAVE_XSLTINIT
        xsltInit();
#endif
        hInstance = hInstDLL;
        DisableThreadLibraryCalls(hInstDLL);
        break;
    case DLL_PROCESS_DETACH:
#ifdef HAVE_LIBXSLT
        xsltCleanupGlobals();
#endif
#ifdef HAVE_LIBXML2
        xmlCleanupParser();
        process_detach();
#endif
        break;
    }
    return TRUE;
}
コード例 #5
0
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);
}
コード例 #6
0
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());
}
コード例 #7
0
int clish_xmldoc_stop(void)
{
#ifdef HAVE_LIB_LIBXSLT
	xsltCleanupGlobals();
#endif
	xmlCleanupParser();
	return 0;
}
コード例 #8
0
ファイル: exportdialog.cpp プロジェクト: KDE/parley
void ExportDialog::accept()
{
    QDialog::accept();

    if (ui->csvRadio->isChecked()) {
        /// Find the CSV filter in the standard filter list
        //!@todo: 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";
}
コード例 #9
0
ファイル: xml_trans.c プロジェクト: bluecherrydvr/omv
/**
 *  Cleanup memory
 */
void
trCleanup()
{
    xsltCleanupGlobals();
    xmlCleanupParser();
#if 0
    xmlMemoryDump();
#endif
}
コード例 #10
0
ファイル: xml-util.c プロジェクト: brsaran/FuzzyApp
/**********************************************************************
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 */
コード例 #11
0
ファイル: xslt.c プロジェクト: kitsune-dsu/kitsune-icecast
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();
}
コード例 #12
0
cepgdata2xmltv::~cepgdata2xmltv ()
{
    if (pxsltStylesheet)
    {
        xsltFreeStylesheet(pxsltStylesheet);
        xsltCleanupGlobals();
        xmlCleanupParser();
    }
    if (dtdmem) {
        free(dtdmem);
        dtdmem=NULL;
    }
}
コード例 #13
0
ファイル: exml.c プロジェクト: playya/Enlightenment
/**
 * Write the transformed xml document out to a memory location.
 * @param   xml The xml document
 * @param  xsl The xml stylesheet
 * @param  params The transform parameters
 * @param   ptr The source xml output location
 * @param   len The size of the memory buffer
 * @return	a pointer to the memory location, or NULL if 
 * @ingroup EXML_XSLT_Group
 */
void *exml_transform_mem_write( EXML *xml, EXML_XSL *xsl, const char *params[],
                                ssize_t *len )
{
	xmlDocPtr res, doc;
	xmlChar *buf;
	int ret;

	CHECK_PARAM_POINTER_RETURN("xml", xml, NULL);
	CHECK_PARAM_POINTER_RETURN("xsl", xsl, NULL);
	
	exml_doc_write(xml, &doc);

	res = xsltApplyStylesheet(xsl->cur, doc, params);

	xmlFreeDoc(doc);

	if( !res ) {
		return NULL;
	}

	ret = xsltSaveResultToString(&buf, len, res, xsl->cur);

	xmlFreeDoc(res);

	if( ret < 0 ) {
		*len = 0;

		xsltCleanupGlobals();

		return NULL;
	}

	ecore_list_append( xsl->buffers, buf );

	xsltCleanupGlobals();

	return buf;
}
コード例 #14
0
ファイル: xslt.cpp プロジェクト: Grandrogue/inkscape_metal
void
XSLT::save(Inkscape::Extension::Output */*module*/, SPDocument *doc, gchar const *filename)
{
    /* TODO: Should we assume filename to be in utf8 or to be a raw filename?
     * See JavaFXOutput::save for discussion. */
    g_return_if_fail(doc != NULL);
    g_return_if_fail(filename != NULL);

    Inkscape::XML::Node *repr = doc->getReprRoot();

    std::string tempfilename_out;
    int tempfd_out = 0;
    try {
        tempfd_out = Inkscape::IO::file_open_tmp(tempfilename_out, "ink_ext_XXXXXX");
    } catch (...) {
        /// \todo Popup dialog here
        return;
    }

    if (!sp_repr_save_rebased_file(repr->document(), tempfilename_out.c_str(), SP_SVG_NS_URI,
                                   doc->getBase(), filename)) {
        throw Inkscape::Extension::Output::save_failed();
    }

    xmlDocPtr svgdoc = xmlParseFile(tempfilename_out.c_str());
    close(tempfd_out);
    if (svgdoc == NULL) {
        return;
    }

    const char * params[1];
    params[0] = NULL;

    xmlDocPtr newdoc = xsltApplyStylesheet(_stylesheet, svgdoc, params);
    //xmlSaveFile(filename, newdoc);
    int success = xsltSaveResultToFilename(filename, newdoc, _stylesheet, 0);

    xmlFreeDoc(newdoc);
    xmlFreeDoc(svgdoc);

    xsltCleanupGlobals();
    xmlCleanupParser();

    if (success < 1) {
        throw Inkscape::Extension::Output::save_failed();
    }

    return;
}
コード例 #15
0
ファイル: xslt.c プロジェクト: balbinus/icecast-kh
void xslt_shutdown(void) {
    int i;

    for(i=0; i < CACHESIZE; i++) {
        free(cache[i].filename);
        free(cache[i].disposition);
        if(cache[i].stylesheet)
            xsltFreeStylesheet(cache[i].stylesheet);
    }

    thread_rwlock_destroy (&xslt_lock);
    thread_spin_destroy (&update_lock);
    xmlCleanupParser();
    xsltCleanupGlobals();
}
コード例 #16
0
ファイル: xslt_lib.c プロジェクト: kannans/ruby-xslt
void ruby_xslt_free( RbTxslt *pRbTxslt ) {
  if( pRbTxslt != NULL ) {
    if( pRbTxslt->tParsedXslt != NULL )
      xsltFreeStylesheet(pRbTxslt->tParsedXslt);
    
    if( pRbTxslt->tXMLDocument != NULL )
      xmlFreeDoc(pRbTxslt->tXMLDocument);
    
    free( pRbTxslt );
  }
  
  xsltCleanupGlobals();
  xmlCleanupParser();
  xmlMemoryDump();
}
コード例 #17
0
ファイル: simple-xmlsec.c プロジェクト: pederbl/xmlsec-ruby
void SecShutdown()
{
  /* Shutdown xmlsec-crypto library */
  xmlSecCryptoShutdown();
  
  /* Shutdown xmlsec library */
  xmlSecShutdown();
  
  /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
  xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
  xmlCleanupParser();
  return ;
}
コード例 #18
0
ファイル: handler_xslt.c プロジェクト: skinkie/webserver
/* Props_free is registered to free our properties
 * after the handler is removed by the webserver.
 * If you put any variables in your props that need
 * to be freed, here is the place. Be smart and check
 * for NULL :)
 */
static ret_t 
props_free (cherokee_handler_xslt_props_t *props)
{
	if (props->global)
		xsltFreeStylesheet(props->global);

	if (props->globalDoc)
		xmlFreeDoc(props->globalDoc);

//	xsltFreeSecurityPrefs(props->sec);
	xsltCleanupGlobals();
	xmlCleanupParser();

	cherokee_buffer_mrproper(&props->content_type);
	cherokee_buffer_mrproper(&props->stylesheet);
	return cherokee_module_props_free_base (MODULE_PROPS(props));
}
コード例 #19
0
ファイル: main.cpp プロジェクト: ShermanHuang/kdesdk
int main(int argc, char *argv[])
{
  xsltStylesheetPtr cur = NULL;
  xmlDocPtr doc, res;

  const char *params[16 + 1];
  int nbparams = 0;
  params[nbparams] = NULL;

  KAboutData aboutData( "umbodoc", 0, ki18n("Umbrello UML Modeller autonomous code generator"),
                        umbrelloVersion(), ki18n(description), KAboutData::License_GPL,
                        ki18n("(c) 2006 Gael de Chalendar (aka Kleag), (c) 2002-2006 Umbrello UML Modeller Authors"), KLocalizedString(),
                        "http://uml.sf.net/");
  aboutData.addAuthor(ki18n("Gael de Chalendar (aka Kleag)"),KLocalizedString(), "*****@*****.**");
  aboutData.addAuthor(ki18n("Umbrello UML Modeller Authors"), KLocalizedString(), "*****@*****.**");
  KCmdLineArgs::init( argc, argv, &aboutData );

  KCmdLineOptions options;
  options.add("+[File]", ki18n("File to transform"));
  options.add("xslt <url>", ki18n("The XSLT file to use"));
  KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.

  KCmdLineArgs *args = KCmdLineArgs::parsedArgs();

  QCStringList xsltOpt = args->getOptionList("xslt");
  if (xsltOpt.size() > 0)
  {
    QString xsltFile(xsltOpt.last());

    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
    cur = xsltParseStylesheetFile((const xmlChar *)xsltFile.latin1());
    doc = xmlParseFile(args->url( 0 ).url().latin1());
    res = xsltApplyStylesheet(cur, doc, params);
    xsltSaveResultToFile(stdout, res, cur);

    xsltFreeStylesheet(cur);
    xmlFreeDoc(res);
    xmlFreeDoc(doc);

    xsltCleanupGlobals();
    xmlCleanupParser();
  }
  return(0);
}
コード例 #20
0
ファイル: smain.cpp プロジェクト: gurucomkz/evcp
void finalize(int errcode=0){
	rep ("Started shutdown sequence..");
		
	timerInit(true);
	bind_pool_clear();
	db_close();

	
	xsltCleanupGlobals();
	xmlCleanupParser();
	//close connections
	
	//-----------------
	if(pidf)
		close(pidf);
	unlink(ConfC("PATH_PIDFILE"));
	rep("SkillPanel server turned off");
	exit(errcode);
}
コード例 #21
0
// ---------------------------------------------------------------------------
// Cleanup wrapper
// ---------------------------------------------------------------------------
//
EXPORT_C void XmlSecCleanup(TAny* globalState)
{
    XmlSecGlobalState* gs = NULL;
    if(globalState)
    {
        gs = reinterpret_cast<XmlSecGlobalState*>(globalState);
    }
    else
    {
        gs = XmlSecGetTls();
    }
    if(!gs)
    {
        return;
    }
    gs->iUserCount--;
    if(gs->iUserCount > 0)
    {
        return;
    }
    // Shutdown xmlsec-crypto library
    xmlSecCryptoShutdown();

    // Shutdown crypto library
    xmlSecCryptoAppShutdown();

    // Shutdown xmlsec library
    xmlSecShutdown();

#ifndef XMLSEC_NO_XSLT
    xsltCleanupGlobals();
#endif /* XMLSEC_NO_XSLT */
    gs->iDOMImpl->Close();
    XmlEngineCleanup();
    if(gs->iKeyManager)
    {
        delete gs->iKeyManager;
    }
    delete gs;
    Dll::SetTls(NULL);
    xmlSecResetErrorFlag();
}
コード例 #22
0
ファイル: libgtodo.c プロジェクト: abderrahim/anjuta
gboolean 
gtodo_client_export(GTodoClient *source, GFile *dest, const gchar *path_to_xsl, gchar **params, GError **error)
{
	xsltStylesheetPtr cur;
	xmlChar *string;
	xmlDocPtr res;
	int length;
	GError *err;

	g_return_val_if_fail(path_to_xsl != NULL, FALSE);

	cur= xsltParseStylesheetFile(BAD_CAST (path_to_xsl));

	if (params == NULL)
	{
		res = xsltApplyStylesheet(cur, source->gtodo_doc, NULL);
	}
	else
	{
		res = xsltApplyStylesheet(cur, source->gtodo_doc, (const char **)params);
	}

	xsltSaveResultToString (&string, &length, res, cur);

	if (!g_file_replace_contents (dest, (char *)string, length, NULL, FALSE,
			G_FILE_CREATE_NONE, NULL, NULL, &err))
	{
		DEBUG_PRINT ("Error exporting file: %s", 
				err->message);
		g_propagate_error (error, err);
	}

	xmlFree (string);
	xsltFreeStylesheet (cur);
	xmlFreeDoc (res);
	xsltCleanupGlobals ();

	return TRUE;
}
コード例 #23
0
ファイル: xml.c プロジェクト: nelsonc/eucalyptus
static void cleanup (void)
{
    xsltCleanupGlobals();
    xmlCleanupParser(); // calls xmlCleanupGlobals()
}
コード例 #24
0
ファイル: applyXSLT.hpp プロジェクト: newle/templatePA
 ~applyXSLT() {
     xsltCleanupGlobals();
     xmlCleanupParser();
 }
コード例 #25
0
ファイル: xsltproc.cpp プロジェクト: adamb924/Gloss
Xsltproc::~Xsltproc()
{
    xsltCleanupGlobals();
    xmlCleanupParser();
}
コード例 #26
0
int 
main(int argc, char **argv) {
    xmlSecKeysMngrPtr mngr;
#ifndef XMLSEC_NO_XSLT
    xsltSecurityPrefsPtr xsltSecPrefs = NULL;
#endif /* XMLSEC_NO_XSLT */

    assert(argv);

    if(argc != 3) {
        fprintf(stderr, "Error: wrong number of arguments.\n");
        fprintf(stderr, "Usage: %s <enc-file> <key-file1> [<key-file2> [...]]\n", argv[0]);
        return(1);
    }

    /* Init libxml and libxslt libraries */
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);
#ifndef XMLSEC_NO_XSLT
    xmlIndentTreeOutput = 1; 
#endif /* XMLSEC_NO_XSLT */

    /* Init libxslt */
#ifndef XMLSEC_NO_XSLT
    /* disable everything */
    xsltSecPrefs = xsltNewSecurityPrefs(); 
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_READ_FILE,        xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_WRITE_FILE,       xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_CREATE_DIRECTORY, xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_READ_NETWORK,     xsltSecurityForbid);
    xsltSetSecurityPrefs(xsltSecPrefs,  XSLT_SECPREF_WRITE_NETWORK,    xsltSecurityForbid);
    xsltSetDefaultSecurityPrefs(xsltSecPrefs); 
#endif /* XMLSEC_NO_XSLT */                

                
    /* Init xmlsec library */
    if(xmlSecInit() < 0) {
        fprintf(stderr, "Error: xmlsec initialization failed.\n");
        return(-1);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
        fprintf(stderr, "Error: loaded xmlsec library version is not compatible.\n");
        return(-1);
    }

    /* Load default crypto engine if we are supporting dynamic
     * loading for xmlsec-crypto libraries. Use the crypto library
     * name ("openssl", "nss", etc.) to load corresponding 
     * xmlsec-crypto library.
     */
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
    if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
        fprintf(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
                        "that you have it installed and check shared libraries path\n"
                        "(LD_LIBRARY_PATH) envornment variable.\n");
        return(-1);     
    }
#endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
        fprintf(stderr, "Error: crypto initialization failed.\n");
        return(-1);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
        fprintf(stderr, "Error: xmlsec-crypto initialization failed.\n");
        return(-1);
    }

    /* create keys manager and load keys */
    mngr = load_des_keys(&(argv[2]), argc - 2);
    if(mngr == NULL) {
        return(-1);
    }

    if(decrypt_file(mngr, argv[1]) < 0) {
        xmlSecKeysMngrDestroy(mngr);    
        return(-1);
    }    

    /* destroy keys manager */
    xmlSecKeysMngrDestroy(mngr);
    
    /* Shutdown xmlsec-crypto library */
    xmlSecCryptoShutdown();
    
    /* Shutdown crypto library */
    xmlSecCryptoAppShutdown();
    
    /* Shutdown xmlsec library */
    xmlSecShutdown();

    /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
    xsltFreeSecurityPrefs(xsltSecPrefs);
    xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
    xmlCleanupParser();
    
    return(0);
}
コード例 #27
0
ファイル: frmReport.cpp プロジェクト: apolyton/pgadmin3
wxString frmReport::XslProcessReport(const wxString &xml, const wxString &xsl)
{
	xmlChar *output = 0;
	xmlDocPtr ssDoc = 0, xmlDoc = 0, resDoc = 0;
	xsltStylesheetPtr ssPtr = 0;
	int length;

	wxBeginBusyCursor();

	// Apply the stylesheet
	xmlSubstituteEntitiesDefault (1); // Substitute entities
	xmlLoadExtDtdDefaultValue = 1; // Load external entities

	// Parse the stylesheet
	ssDoc = xmlParseDoc(XML_FROM_WXSTRING(xsl));
	if (!ssDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XML stylesheet!"));
		goto cleanup;
	}

	ssPtr = xsltParseStylesheetDoc(ssDoc);
	if (!ssPtr)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XSL stylesheet!"));
		goto cleanup;
	}

	// Parse the data
	xmlDoc = xmlParseDoc(XML_FROM_WXSTRING(xml));
	if (!xmlDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to parse the XML document!"));
		goto cleanup;
	}

	// Apply the stylesheet
	resDoc = xsltApplyStylesheet(ssPtr, xmlDoc, NULL);
	if (!resDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to apply the XSL stylesheet to the XML document!"));
		goto cleanup;
	}

	// Get the result
	xsltSaveResultToString (&output, &length, resDoc, ssPtr);
	if (!resDoc)
	{
		wxEndBusyCursor();
		wxLogError(_("Failed to read the processed document!"));
		goto cleanup;
	}

cleanup:

	// Cleanup
	if (resDoc)
		xmlFreeDoc(resDoc);

	if (xmlDoc)
		xmlFreeDoc(xmlDoc);

	if (ssPtr)
		xsltFreeStylesheet(ssPtr);

	// This crashes - dunno why :-(
	// if (ssDoc)
	//  xmlFreeDoc(ssDoc);

	xsltCleanupGlobals();

	wxEndBusyCursor();

	if (output)
		return WXSTRING_FROM_XML(output);
	else
		return wxEmptyString;
}
コード例 #28
0
 ~TXsltIniter() throw () {
     xsltCleanupGlobals();
 }
コード例 #29
0
ファイル: xsl.cpp プロジェクト: BackupTheBerlios/sim-im-svn
void XSL::cleanup()
{
    xsltCleanupGlobals();
}
コード例 #30
0
ファイル: sign2.c プロジェクト: Arcenciel/DDReader
int 
main(int argc, char **argv) {
    assert(argv);

    if(argc != 3) {
	printf_a_ignorar3(stderr, "Error: wrong number of arguments.\n");
	printf_a_ignorar3(stderr, "Usage: %s <xml-file> <key-file>\n", argv[0]);
	return(1);
    }

    /* Init libxml and libxslt libraries */
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);
#ifndef XMLSEC_NO_XSLT
    xmlIndentTreeOutput = 1; 
#endif /* XMLSEC_NO_XSLT */
        	
    /* Init xmlsec library */
    if(xmlSecInit() < 0) {
	printf_a_ignorar3(stderr, "Error: xmlsec initialization failed.\n");
	return(-1);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
	printf_a_ignorar3(stderr, "Error: loaded xmlsec library version is not compatible.\n");
	return(-1);
    }

    /* Load default crypto engine if we are supporting dynamic
     * loading for xmlsec-crypto libraries. Use the crypto library
     * name ("openssl", "nss", etc.) to load corresponding 
     * xmlsec-crypto library.
     */
#ifdef XMLSEC_CRYPTO_DYNAMIC_LOADING
    if(xmlSecCryptoDLLoadLibrary(BAD_CAST XMLSEC_CRYPTO) < 0) {
	printf_a_ignorar3(stderr, "Error: unable to load default xmlsec-crypto library. Make sure\n"
			"that you have it installed and check shared libraries path\n"
			"(LD_LIBRARY_PATH) envornment variable.\n");
	return(-1);	
    }
#endif /* XMLSEC_CRYPTO_DYNAMIC_LOADING */

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
	printf_a_ignorar3(stderr, "Error: crypto initialization failed.\n");
	return(-1);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
	printf_a_ignorar3(stderr, "Error: xmlsec-crypto initialization failed.\n");
	return(-1);
    }

    if(sign_file(argv[1], argv[2]) < 0) {
	return(-1);
    }    
    
    /* Shutdown xmlsec-crypto library */
    xmlSecCryptoShutdown();
    
    /* Shutdown crypto library */
    xmlSecCryptoAppShutdown();
    
    /* Shutdown xmlsec library */
    xmlSecShutdown();

    /* Shutdown libxslt/libxml */
#ifndef XMLSEC_NO_XSLT
    xsltCleanupGlobals();            
#endif /* XMLSEC_NO_XSLT */
    xmlCleanupParser();
    
    return(0);
}