diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2001-10-22 09:46:13 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2001-10-22 09:46:13 +0000 |
commit | 89cad536e3e38002bfc931acfa2e0645d4b08a51 (patch) | |
tree | 968ac11e7679f2b253e84a3c1d5c61cfe80afb09 /xmllint.c | |
parent | 0a702dcab334c3cb9b702d8f59d79d8f00bc18df (diff) | |
download | libxml2-89cad536e3e38002bfc931acfa2e0645d4b08a51.tar.gz |
added entities testing to the Thread test make the test reasonable fix the
* test/threads/*: added entities testing to the Thread test
* testThreads.c: make the test reasonable
* DOCBparser.c: fix the DTD public and system ID
* xmllint.c: added --sgml for SGML DocBook importing
* Makefile.am: added Docbtests target
Daniel
Diffstat (limited to 'xmllint.c')
-rw-r--r-- | xmllint.c | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -68,6 +68,9 @@ #ifdef LIBXML_CATALOG_ENABLED #include <libxml/catalog.h> #endif +#ifdef LIBXML_DOCB_ENABLED +#include <libxml/DOCBparser.h> +#endif #include <libxml/globals.h> #ifdef LIBXML_DEBUG_ENABLED @@ -86,6 +89,9 @@ static char * dtdvalid = NULL; static int repeat = 0; static int insert = 0; static int compress = 0; +#ifdef LIBXML_DOCB_ENABLED +static int sgml = 0; +#endif static int html = 0; static int htmlout = 0; static int push = 0; @@ -412,6 +418,38 @@ static void parseAndPrintFile(char *filename) { xmlDocSetRootElement(doc, n); } } +#ifdef LIBXML_DOCB_ENABLED + /* + * build an SGML tree from a string; + */ + else if ((sgml) && (push)) { + FILE *f; + + f = fopen(filename, "r"); + if (f != NULL) { + int res, size = 3; + char chars[4096]; + docbParserCtxtPtr ctxt; + + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = docbCreatePushParserCtxt(NULL, NULL, + chars, res, filename, 0); + while ((res = fread(chars, 1, size, f)) > 0) { + docbParseChunk(ctxt, chars, res, 0); + } + docbParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + docbFreeParserCtxt(ctxt); + } + fclose(f); + } + } else if (sgml) { + doc = docbParseFile(filename, NULL); + } +#endif #ifdef LIBXML_HTML_ENABLED else if (html) { doc = htmlParseFile(filename, NULL); @@ -789,6 +827,9 @@ static void usage(const char *name) { printf("\t--repeat : repeat 100 times, for timing or profiling\n"); printf("\t--insert : ad-hoc test for valid insertions\n"); printf("\t--compress : turn on gzip compression of output\n"); +#ifdef LIBXML_DOCB_ENABLED + printf("\t--sgml : use the DocBook SGML parser\n"); +#endif #ifdef LIBXML_HTML_ENABLED printf("\t--html : use the HTML parser\n"); #endif @@ -856,6 +897,12 @@ main(int argc, char **argv) { else if ((!strcmp(argv[i], "-htmlout")) || (!strcmp(argv[i], "--htmlout"))) htmlout++; +#ifdef LIBXML_DOCB_ENABLED + else if ((!strcmp(argv[i], "-sgml")) || + (!strcmp(argv[i], "--sgml"))) { + sgml++; + } +#endif #ifdef LIBXML_HTML_ENABLED else if ((!strcmp(argv[i], "-html")) || (!strcmp(argv[i], "--html"))) { |