Пример #1
0
void xslt_initialize()
{
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;

    memset(cache, 0, sizeof(stylesheet_cache_t)*CACHESIZE);
    thread_mutex_create(&xsltlock);
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
}
Пример #2
0
/*
 * call-seq:
 *    XML.default_substitute_entities = true|false
 *
 * Controls whether parsers perform inline entity substitution
 * (for external entities) by default.
 */
static VALUE rxml_default_substitute_entities_set(VALUE klass, VALUE value)
{
  if (value == Qfalse)
  {
    xmlSubstituteEntitiesDefault(0);
    return (Qfalse);
  }
  else
  {
    xmlSubstituteEntitiesDefault(1);
    return (Qtrue);
  }
}
Пример #3
0
int main(int argc, char **argv) {
    int i;
    int files = 0;

    if (argc <= 1) {
	usage(argv[0]);
	return(1);
    }
    LIBXML_TEST_VERSION
    for (i = 1; i < argc ; i++) {
	if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
	    debug++;
	else if ((!strcmp(argv[i], "-dump")) || (!strcmp(argv[i], "--dump")))
	    dump++;
	else if ((!strcmp(argv[i], "-count")) || (!strcmp(argv[i], "--count")))
	    count++;
	else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
	    valid++;
	else if ((!strcmp(argv[i], "-noent")) ||
	         (!strcmp(argv[i], "--noent")))
	    noent++;
    }
    if (noent != 0) xmlSubstituteEntitiesDefault(1);
    for (i = 1; i < argc ; i++) {
	if (argv[i][0] != '-') {
	    handleFile(argv[i]);
	    files ++;
	}
    }
    xmlCleanupParser();
    xmlMemoryDump();

    return(0);
}
Пример #4
0
int xmlsec_init() {
    /* init libxml lib */
    xmlInitParser();
    xmlIndentTreeOutput = 1; 
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);

    /* init xmlsec lib */
    if(xmlSecInit() < 0) {
        dcp_log(OPENDCP_ERROR,"Error: xmlsec initialization failed.");
        return(OPENDCP_ERROR);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
        dcp_log(OPENDCP_ERROR, "Error: loaded xmlsec library version is not compatible.");
        return(OPENDCP_ERROR);
    }

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
        dcp_log(OPENDCP_ERROR, "Error: crypto initialization failed.");
        return(OPENDCP_ERROR);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
        dcp_log(OPENDCP_ERROR, "Error: xmlsec-crypto initialization failed.");
        return(OPENDCP_ERROR);
    }

    return(OPENDCP_NO_ERROR);
}
Пример #5
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;
}
Пример #6
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);
}
void
yum_xml_parse_filelists (const char *filename,
                         CountFn count_callback,
                         PackageFn package_callback,
                         gpointer user_data,
                         GError **err)
{
    FilelistSAXContext ctx;
    SAXContext *sctx = &ctx.sctx;

    int rc;

    ctx.state = FILELIST_PARSER_TOPLEVEL;
    ctx.current_file = NULL;
    
    sax_context_init(sctx, "filelists.xml", count_callback, package_callback,
                     user_data, err);

    xmlSubstituteEntitiesDefault (1);
    rc = xmlSAXUserParseFile (&filelist_sax_handler, &ctx, filename);

    if (sctx->current_package) {
        g_warning ("Incomplete package lost");
        package_free (sctx->current_package);
    }

    if (ctx.current_file)
        g_free (ctx.current_file);

    g_string_free (sctx->text_buffer, TRUE);
}
Пример #8
0
int xmlsec_verify_init() {
    /* init libxml lib */
    xmlInitParser();
    xmlIndentTreeOutput = 1; 
    LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault(1);

    /* init xmlsec lib */
    if(xmlSecInit() < 0) {
        dcp_log(DCP_FATAL,"xmlsec initialization failed");
        return(DCP_FATAL);
    }

    /* Check loaded library version */
    if(xmlSecCheckVersion() != 1) {
        dcp_log(DCP_FATAL, "loaded xmlsec library version is not compatible");
        return(DCP_FATAL);
    }

    /* Init crypto library */
    if(xmlSecCryptoAppInit(NULL) < 0) {
        dcp_log(DCP_FATAL, "crypto initialization failed");
        return(DCP_FATAL);
    }

    /* Init xmlsec-crypto library */
    if(xmlSecCryptoInit() < 0) {
        dcp_log(DCP_FATAL, "xmlsec-crypto initialization failed");
        return(DCP_FATAL);
    }

    return(DCP_SUCCESS);
}
Пример #9
0
static int
raptor_rss_parse_init(raptor_parser* rdf_parser, const char *name) {
  raptor_rss_parser_context *rss_parser=(raptor_rss_parser_context*)rdf_parser->context;
  int i;
  
  RAPTOR_RDF_type_URI(rss_parser)=raptor_new_uri_for_rdf_concept("type");
  RAPTOR_RDF_Seq_URI(rss_parser)=raptor_new_uri_for_rdf_concept("Seq");

  for(i=0; i<RSS_NAMESPACES_SIZE;i++) {
    const char *uri_string=rss_namespace_uri_strings[i];
    if(uri_string)
      rss_parser->namespace_uris[i]=raptor_new_uri((const unsigned char*)uri_string);
  }

  for(i=0; i< RAPTOR_RSS_COMMON_SIZE; i++) {
    raptor_uri *namespace_uri=rss_parser->namespace_uris[raptor_rss_types_info[i].nspace];
    if(namespace_uri)
      raptor_rss_types_info[i].uri=raptor_new_uri_from_uri_local_name(namespace_uri,
                                                                      (const unsigned char*)raptor_rss_types_info[i].name);
  }

  for(i=0; i< RAPTOR_RSS_FIELDS_SIZE; i++) {
    raptor_uri *namespace_uri=rss_parser->namespace_uris[raptor_rss_fields_info[i].nspace];
    if(namespace_uri)
      raptor_rss_fields_info[i].uri=raptor_new_uri_from_uri_local_name(namespace_uri,
                                                                       (const unsigned char*)raptor_rss_fields_info[i].name);
  }

  xmlSubstituteEntitiesDefault(1);

  return 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());
}
Пример #11
0
void initialize(void)
{
    xmlInitParser();
    xmlSubstituteEntitiesDefault(1);
    doc = xmlNewDoc(BAD_CAST "1.0");
    root_node = xmlNewNode(NULL, BAD_CAST "_R_");
    xmlDocSetRootElement(doc, root_node);
}
Пример #12
0
XSLTUtils::XSLTUtils() :
m_xmlInput(nullptr), m_xmlOutput(nullptr), m_xmlStylesheet(nullptr), m_xsltStylesheet(nullptr)
{
  // initialize libxslt
  xmlSubstituteEntitiesDefault(1);
  xmlLoadExtDtdDefaultValue = 0;
  xsltSetGenericErrorFunc(NULL, err);
}
Пример #13
0
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";
}
Пример #14
0
void xslt_initialize(void)
{
    memset(cache, 0, sizeof(stylesheet_cache_t)*CACHESIZE);
    thread_mutex_create(&xsltlock);
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
}
Пример #15
0
/* functions */
int verify_file(const char* xmlMessage, const char* key) {
  xmlDocPtr doc = NULL;
  /* Init libxml and libxslt libraries */
  xmlInitParser();
  LIBXML_TEST_VERSION
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
  xmlSubstituteEntitiesDefault(1);
  doc = xmlParseDoc((xmlChar *) xmlMessage) ;
  return verify_document(doc, key);
}
Пример #16
0
//#if !EPUB_COMPILER(MSVC)
//__attribute__((destructor))
//#endif
void __resetLibXMLOverrides(void)
{
    xmlRegisterNodeDefault(defNodeRegister);
    xmlThrDefRegisterNodeDefault(defThrNodeRegister);
    xmlDeregisterNodeDefault(defNodeDeregister);
    xmlThrDefDeregisterNodeDefault(defThrNodeDeregister);
    
    xmlSubstituteEntitiesDefault(0);
    xmlLoadExtDtdDefaultValue = 0;
}
Пример #17
0
/**********************************************************************
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 */
Пример #18
0
void xslt_initialize(void)
{
    memset (&cache[0], 0, sizeof cache);
    thread_rwlock_create (&xslt_lock);
    thread_spin_create (&update_lock);
    xsl_updating = 0;
    xmlInitParser();
    LIBXML_TEST_VERSION
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
}
Пример #19
0
XSLPrivate::XSLPrivate(const char *my_xsl)
{
    styleSheet = NULL;
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
    doc = xmlParseMemory(my_xsl, strlen(my_xsl));
    if (doc == NULL){
        log(L_WARN, "Can't parse XSLT");
        return;
    }
    styleSheet = xsltParseStylesheetDoc(doc);
}
Пример #20
0
Xsltproc::Xsltproc() :
    mErrorRedirect(false)
{
    exsltRegisterAll();
    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
    mStylesheet = 0;
    mOutput = 0;
    mXml = 0;
    mParams = 0;
    mNParams = 0;
}
Пример #21
0
/*
 * Initialize for xml parsing.
 */
void
pgxml_parser_init(void)
{
	/* Set up error handling (we share the core's error handler) */
	pg_xml_init();

	/* Initialize libxml */
	xmlInitParser();

	xmlSubstituteEntitiesDefault(1);
	xmlLoadExtDtdDefaultValue = 1;
}
Пример #22
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;
}
Пример #23
0
Pvoid_t html_tokenize_into_features(const char * html, Pvoid_t features) {
	xmlSubstituteEntitiesDefault(0);
	htmlDocPtr doc = htmlParseDoc(BAD_CAST html, "UTF-8");

	if (doc) {
		Buffer *buf = extractText(doc);
		features = tokenize_text(buf->buf, buf->length, features);
		features = tokenize_uris(doc, features);
		free_buffer(buf);
		xmlFreeDoc(doc);
	}

	return features;
}
Пример #24
0
//INITIALIZER(__setupLibXML)
void __setupLibXML(void)
{
    xmlInitGlobals();
    defNodeRegister = xmlRegisterNodeDefault(&__registerNode);
    defThrNodeDeregister = xmlThrDefRegisterNodeDefault(&__registerNodeThr);
    defNodeDeregister = xmlDeregisterNodeDefault(&__deregisterNode);
    defThrNodeDeregister = xmlThrDefDeregisterNodeDefault(&__deregisterNodeThr);

    xmlSubstituteEntitiesDefault(1);
    xmlLoadExtDtdDefaultValue = 1;
//#if EPUB_COMPILER(MSVC)
//    atexit(__resetLibXMLOverrides);
//#endif
}
Пример #25
0
int
main(int argc, char *argv[])
{
    char *filename = "test.xml";
    xmlDocPtr doc;

    if(argc > 1)
	filename = argv[1];

    xmlSubstituteEntitiesDefault(1);   

    doc = xmlParseFile(filename);

    return(doc == NULL);
}
Пример #26
0
InputPadGroup *
input_pad_group_append_from_file (InputPadGroup        *group,
                                  const gchar          *file,
                                  const gchar          *domain)
{
    InputPadGroup **pgroup = &group;
    xmlDocPtr doc;
    xmlNodePtr node;

    xmlInitParser ();
    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
    xmlSubstituteEntitiesDefault (1);

    xml_file = file;
    translation_domain = domain;
    doc = xmlParseFile (xml_file);
    if (doc == NULL || xmlDocGetRootElement (doc) == NULL) {
        g_error ("Unable to parse file: %s", xml_file);
    }

    node = xmlDocGetRootElement (doc);
    if (node == NULL) {
        g_error ("Top node not found: %s", xml_file);
    }

    if (g_strcmp0 ((gchar *) node->name, "input-pad")) {
        g_error ("The first tag should be <input-pad>: %s", xml_file);
    }
    if (node->children == NULL) {
        g_error ("tag %s does not have child tags in the file %s",
                 (char *) node->name, xml_file);
    }

    while (pgroup && *pgroup) {
        pgroup = &((*pgroup)->next);
    }
    parse_input_pad (node->children, pgroup);

    xmlFreeDoc (doc);
    xmlCleanupParser ();

    xml_file = NULL;
    translation_domain = NULL;

    return group;
}
Пример #27
0
//!
//! Initialize the XML local parameters from the NC state structure.
//!
//! @param[in] nc_state a pointer to the NC state structure to initialize
//!
static void init_xml(void)
{
    pthread_mutex_lock(&xml_mutex);
    {
        if (!initialized) {
            xmlIndentTreeOutput = 1;
            xmlKeepBlanksDefault(0);
            xmlInitParser();
            LIBXML_TEST_VERSION;       // verifies that loaded library matches the compiled library
            xmlSubstituteEntitiesDefault(1);    // substitute entities while parsing
            xmlSetGenericErrorFunc(NULL, error_handler);    // catches errors/warnings that libxml2 writes to stderr
            xsltSetGenericErrorFunc(NULL, error_handler);   // catches errors/warnings that libslt writes to stderr
            initialized = TRUE;
        }
    }
    pthread_mutex_unlock(&xml_mutex);
}
Пример #28
0
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);
}
Пример #29
0
/**
 * Initialize an xml stylesheet structure to some sane starting values.
 * @param   xsl The stylesheet to initialize.
 * @return  @c TRUE if successful, @c FALSE if an error occurs.
 * @ingroup EXML_XSLT_Group
 */
int exml_xsl_init( EXML_XSL *xsl, char *filename )
{
	CHECK_PARAM_POINTER_RETURN("xsl", xsl, FALSE);

	xmlSubstituteEntitiesDefault(1);

	xmlLoadExtDtdDefaultValue = 1;

	xsl->buffers = ecore_list_new();
	ecore_list_free_cb_set(xsl->buffers, ECORE_FREE_CB(xmlFree));

	xsl->cur = xsltParseStylesheetFile((const xmlChar *) filename);

	if( !xsl->cur )
		return FALSE;

	return TRUE;
}
Пример #30
0
/*
 * Initialize for xml parsing.
 *
 * As with the underlying pg_xml_init function, calls to this MUST be followed
 * by a PG_TRY block that guarantees that pg_xml_done is called.
 */
PgXmlErrorContext *
pgxml_parser_init(PgXmlStrictness strictness)
{
	PgXmlErrorContext *xmlerrcxt;

	/* Set up error handling (we share the core's error handler) */
	xmlerrcxt = pg_xml_init(strictness);

	/* Note: we're assuming an elog cannot be thrown by the following calls */

	/* Initialize libxml */
	xmlInitParser();

	xmlSubstituteEntitiesDefault(1);
	xmlLoadExtDtdDefaultValue = 1;

	return xmlerrcxt;
}