/* * call-seq: * document.debug_dump([stream]) -> true * * Debug version of dump. */ VALUE ruby_xml_document_debug_dump(int argc, VALUE *argv, VALUE self) { #ifdef LIBXML_DEBUG_ENABLED OpenFile *fptr; VALUE io; FILE *out; ruby_xml_document_t *rxd; Data_Get_Struct(self, ruby_xml_document_t, rxd); if (rxd->doc == NULL) return(Qnil); switch (argc) { case 0: io = rb_stderr; break; case 1: io = argv[0]; if (!rb_obj_is_kind_of(io, rb_cIO)) rb_raise(rb_eTypeError, "need an IO object"); break; default: rb_raise(rb_eArgError, "wrong number of arguments (0 or 1)"); } GetOpenFile(io, fptr); rb_io_check_writable(fptr); out = GetWriteFile(fptr); xmlDebugDumpDocument(out, rxd->doc); return(Qtrue); #else rb_warn("libxml was compiled without debugging support. Please recompile libxml and ruby-libxml"); return(Qfalse); #endif }
/* * call-seq: * node.debug -> true|false * * Print libxml debugging information to stdout. * Requires that libxml was compiled with debugging enabled. */ static VALUE rxml_document_debug(VALUE self) { #ifdef LIBXML_DEBUG_ENABLED xmlDocPtr xdoc; Data_Get_Struct(self, xmlDoc, xdoc); xmlDebugDumpDocument(NULL, xdoc); return Qtrue; #else rb_warn("libxml was compiled without debugging support.") return Qfalse; #endif }
static void xsltProcess(xmlDocPtr doc, xsltStylesheetPtr cur, const char *filename) { xmlDocPtr res; #ifdef LIBXML_XINCLUDE_ENABLED if (xinclude) { if (timing) gettimeofday(&begin, NULL); xmlXIncludeProcess(doc); if (timing) { long msec; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; fprintf(stderr, "XInclude processing %s took %ld ms\n", filename, msec); } } #endif if (timing) gettimeofday(&begin, NULL); if (output == NULL) { if (repeat) { int j; for (j = 1; j < repeat; j++) { res = xsltApplyStylesheet(cur, doc, params); xmlFreeDoc(res); xmlFreeDoc(doc); #ifdef LIBXML_HTML_ENABLED if (html) doc = htmlParseFile(filename, NULL); else #endif #ifdef LIBXML_DOCB_ENABLED if (docbook) doc = docbParseFile(filename, NULL); else #endif doc = xmlParseFile(filename); } } if (profile) { res = xsltProfileStylesheet(cur, doc, params, stderr); } else { res = xsltApplyStylesheet(cur, doc, params); } if (timing) { long msec; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; if (repeat) fprintf(stderr, "Applying stylesheet %d times took %ld ms\n", repeat, msec); else fprintf(stderr, "Applying stylesheet took %ld ms\n", msec); } xmlFreeDoc(doc); if (res == NULL) { fprintf(stderr, "no result for %s\n", filename); return; } if (noout) { xmlFreeDoc(res); return; } #ifdef LIBXML_DEBUG_ENABLED if (debug) xmlDebugDumpDocument(stdout, res); else { #endif if (cur->methodURI == NULL) { if (timing) gettimeofday(&begin, NULL); xsltSaveResultToFile(stdout, res, cur); if (timing) { long msec; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; fprintf(stderr, "Saving result took %ld ms\n", msec); } } else { if (xmlStrEqual (cur->method, (const xmlChar *) "xhtml")) { fprintf(stderr, "non standard output xhtml\n"); if (timing) gettimeofday(&begin, NULL); xsltSaveResultToFile(stdout, res, cur); if (timing) { long msec; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; fprintf(stderr, "Saving result took %ld ms\n", msec); } } else { fprintf(stderr, "Unsupported non standard output %s\n", cur->method); } } #ifdef LIBXML_DEBUG_ENABLED } #endif xmlFreeDoc(res); } else { xsltRunStylesheet(cur, doc, params, output, NULL, NULL); if (timing) { long msec; gettimeofday(&end, NULL); msec = end.tv_sec - begin.tv_sec; msec *= 1000; msec += (end.tv_usec - begin.tv_usec) / 1000; fprintf(stderr, "Running stylesheet and saving result took %ld ms\n", msec); } xmlFreeDoc(doc); } }