Beispiel #1
0
static int internal_convert_xml2lpc(xml2lpc_context *ctx) {
	xmlNode *rootNode;
	int ret;

	xml2lpc_log(ctx, XML2LPC_DEBUG, "Parse started");
	rootNode = xmlDocGetRootElement(ctx->doc);
	//dumpNodes(0, rootNode, cbf, ctx);
	ret = processDoc(rootNode, ctx);
	xml2lpc_log(ctx, XML2LPC_DEBUG, "Parse ended ret:%d", ret);
	return ret;
}
Beispiel #2
0
static int internal_convert_lpc2xml(lpc2xml_context *ctx) {
	int ret = 0;
	xmlDoc *doc;
	lpc2xml_log(ctx, LPC2XML_DEBUG, "Generation started");
	if(ctx->doc != NULL) {
		xmlFreeDoc(ctx->doc);
		ctx->doc = NULL;
	}
	doc = xmlNewDoc((const xmlChar *)"1.0");
	ret  = processDoc(doc, ctx);
	if(ret == 0) {
		ctx->doc = doc;
	} else {
		xmlFreeDoc(doc);
	}
	lpc2xml_log(ctx, LPC2XML_DEBUG, "Generation ended ret:%d", ret);
	return ret;
}
WebPage::WebPage(string & doc, Configuration & config, WordSegmentation & jieba)
	: _doc(doc)
{
	_topWords.reserve(10);
	processDoc(doc, config, jieba);
}
Beispiel #4
0
int main(int argc, char **argv) {
    xmlTextReaderPtr readerPtr;
    int i;
    xmlDocPtr docPtr;

    if (argc < 2)
        return(1);

    /*
     * this initialises the library and check potential ABI mismatches
     * between the version it was compiled for and the actual shared
     * library used.
     */
    LIBXML_TEST_VERSION

    /*
     * Create a new reader for the first file and process the
     * document.
     */
    readerPtr = xmlReaderForFile(argv[1], NULL, 0);
    if (NULL == readerPtr) {
      fprintf(stderr, "%s: failed to create reader\n", argv[1]);      
      return(1);
    }
    processDoc(readerPtr);

    /*
     * The reader can be reused for subsequent files.
     */
    for (i=2; i < argc; ++i) {
      	xmlReaderNewFile(readerPtr, argv[i], NULL, 0);
	if (NULL == readerPtr) {
	  fprintf(stderr, "%s: failed to create reader\n", argv[i]);      
	  return(1);
	}
        processDoc(readerPtr);
    }

    /*
     * Since we've called xmlTextReaderCurrentDoc, we now have to
     * clean up after ourselves.  We only have to do this the last
     * time, because xmlReaderNewFile calls xmlCtxtReset which takes
     * care of it.
     */
    docPtr = xmlTextReaderCurrentDoc(readerPtr);
    if (docPtr != NULL)
      xmlFreeDoc(docPtr);

    /*
     * Clean up the reader.
     */
    xmlFreeTextReader(readerPtr);

    /*
     * Cleanup function for the XML library.
     */
    xmlCleanupParser();
    /*
     * this is to debug memory for regression tests
     */
    xmlMemoryDump();
    return(0);
}