deps/kb_meme/meme-5.0.1/src/xml-util.c
/**********************************************************************
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.
**********************************************************************/
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.
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 .
bool print_xml_filename_to_filename_using_stylesheet(
    char* input_file_path,        
    char* stylesheet_file_path,   
    char* output_file_path        
) {
  xsltStylesheetPtr stylesheet = NULL;
  xmlDocPtr input_doc = NULL;
  xmlDocPtr output_doc = NULL;
  const int PERFORM_ENTITY_SUBST = 1;
  xmlSubstituteEntitiesDefault(PERFORM_ENTITY_SUBST);
  xmlLoadExtDtdDefaultValue = 0;
  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;
}
bool print_xml_filename_to_filename_using_stylesheet ( char * input_file_path , char * stylesheet_file_path , char * output_file_path ) { xsltStylesheetPtr stylesheet = NULL ; xmlDocPtr input_doc = NULL ; xmlDocPtr output_doc = NULL ; const int PERFORM_ENTITY_SUBST = 1 ; xmlSubstituteEntitiesDefault ( PERFORM_ENTITY_SUBST ) ; xmlLoadExtDtdDefaultValue = 0 ; stylesheet = xsltParseStylesheetFile ( ( const xmlChar * ) stylesheet_file_path ) ; if ( ! stylesheet ) { fprintf ( stderr , " \n " , stylesheet_file_path ) ; return false ; } input_doc = xmlParseFile ( input_file_path ) ; if ( ! input_doc ) { fprintf ( stderr , " \n " , input_file_path ) ; return false ; } output_doc = xsltApplyStylesheet ( stylesheet , input_doc , NULL ) ; if ( ! output_doc ) { fprintf ( stderr , " \n " , stylesheet_file_path , input_file_path ) ; return false ; } int result = xsltSaveResultToFilename ( output_file_path , output_doc , stylesheet , 0 ) ; if ( result == -1 ) { fprintf ( stderr , " \n " , stylesheet_file_path , output_file_path ) ; } xsltFreeStylesheet ( stylesheet ) ; xmlFreeDoc ( output_doc ) ; xmlFreeDoc ( input_doc ) ; xsltCleanupGlobals ( ) ; xmlCleanupParser ( ) ; return true ; }
print_xml_filename_to_filename_using_stylesheet
Print the contents of an XML file to another file applying an
XSLT stylesheet.
print_xml_filename_to_filename_using_stylesheet Print the contents of an XML file to another file applying an XSLT stylesheet .
/* path to XML input file IN */ /* path to MEME XSL stylesheet IN */ /* path to HTML output file IN */