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
diff --git a/ChangeLog b/ChangeLog
index b7ed1c5..50139f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Mon Oct 22 11:32:36 CEST 2001 Daniel Veillard <daniel@veillard.com>
+
+ * 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
+
Fri Oct 19 11:47:13 CEST 2001 Daniel Veillard <daniel@veillard.com>
* nanoftp.c: use only "anonymous@" string for anonymous passwds
diff --git a/DOCBparser.c b/DOCBparser.c
index 5ea8b0a..013e819 100644
--- a/DOCBparser.c
+++ b/DOCBparser.c
@@ -48,6 +48,15 @@
#include <libxml/globals.h>
/*
+ * DocBook XML current versions
+ */
+
+#define XML_DOCBOOK_XML_PUBLIC (const xmlChar *) \
+ "-//OASIS//DTD DocBook XML V4.1.2//EN"
+#define XML_DOCBOOK_XML_SYSTEM (const xmlChar *) \
+ "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"
+
+/*
* Internal description of an SGML entity
*/
typedef struct _docbEntityDesc docbEntityDesc;
@@ -3554,17 +3563,20 @@
/*
* Create or update the document accordingly to the DOCTYPE
+ * But use the predefined PUBLIC and SYSTEM ID of DocBook XML
*/
if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
(!ctxt->disableSAX))
- ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
+ ctxt->sax->internalSubset(ctxt->userData, name,
+ XML_DOCBOOK_XML_PUBLIC,
+ XML_DOCBOOK_XML_SYSTEM);
- /*
- * Is there any internal subset declarations ?
- * they are handled separately in docbParseInternalSubset()
- */
- if (RAW != '[') {
- return;
+ if (RAW != '>') {
+ if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
+ ctxt->sax->error(ctxt->userData,
+ "docbParseDocTypeDecl : internal subset not handled\n");
+ } else {
+ NEXT;
}
/*
diff --git a/Makefile.am b/Makefile.am
index c87ca99..36dcce5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,8 +1,5 @@
## Process this file with automake to produce Makefile.in
-# Dependancies are fucked in make distcheck could not find why :-(
-AUTOMAKE_OPTIONS=no-dependencies
-
SUBDIRS = include . doc example
INCLUDES = -I@srcdir@/include -I$(top_builddir)/include @THREAD_CFLAGS@ @Z_CFLAGS@
@@ -226,6 +223,26 @@
rm result.$$name result2.$$name ; \
fi ; fi ; done)
+Docbtests : xmllint
+ @(echo > .memdump)
+ @echo "##"
+ @echo "## SGML DocBook regression tests"
+ @echo "##"
+ @(for i in $(srcdir)/test/DocBook/*.sgm ; do \
+ name=`basename $$i .sgm`; \
+ if [ ! -d $$i ] ; then \
+ if [ ! -f $(srcdir)/result/DocBook/$$name.xml ] ; then \
+ echo New test file $$name ; \
+ $(top_builddir)/xmllint --sgml $$i > $(srcdir)/result/DocBook/$$name.xml ; \
+ $(top_builddir)/xmllint --valid --noout $(srcdir)/result/DocBook/$$name.xml ; \
+ else \
+ echo Testing $$name ; \
+ $(top_builddir)/xmllint --sgml $$i > result.$$name ; \
+ diff $(srcdir)/result/DocBook/$$name.xml result.$$name ; \
+ $(top_builddir)/xmllint --valid --noout result.$$name ; \
+ rm result.$$name ; \
+ fi ; fi ; done)
+
XMLenttests : xmllint
@(echo > .memdump)
@echo "##"
diff --git a/test/threads/a/a.dtd b/test/threads/a/a.dtd
index 7699a22..b298085 100644
--- a/test/threads/a/a.dtd
+++ b/test/threads/a/a.dtd
@@ -1 +1 @@
-<!ELEMENT a EMPTY>
+<!ELEMENT a (#PCDATA)>
diff --git a/test/threads/abc.xml b/test/threads/abc.xml
index 1c3bb96..ee98144 100644
--- a/test/threads/abc.xml
+++ b/test/threads/abc.xml
@@ -1,7 +1,7 @@
<!DOCTYPE abc SYSTEM "http://example.org/abc.dtd">
<abc>
- <a/>
- <b/>
+ <a>Let's use predefined entites & < ></a>
+ <b>Let's use a DTD defined entity &bent;</b>
<c/>
</abc>
diff --git a/test/threads/acb.xml b/test/threads/acb.xml
index af2030e..a14e362 100644
--- a/test/threads/acb.xml
+++ b/test/threads/acb.xml
@@ -1,7 +1,7 @@
<!DOCTYPE acb SYSTEM "http://example.org/acb.dtd">
<acb>
- <a/>
+ <a>Let's use predefined entites & < ></a>
<c/>
- <b/>
+ <b>Let's use a DTD defined entity &bent;</b>
</acb>
diff --git a/test/threads/b/b.dtd b/test/threads/b/b.dtd
index c1435a8..59de88e 100644
--- a/test/threads/b/b.dtd
+++ b/test/threads/b/b.dtd
@@ -1 +1,2 @@
-<!ELEMENT b EMPTY>
+<!ELEMENT b (#PCDATA)>
+<!ENTITY bent "the b entity">
diff --git a/test/threads/bac.xml b/test/threads/bac.xml
index 51799e4..63d6efc 100644
--- a/test/threads/bac.xml
+++ b/test/threads/bac.xml
@@ -1,7 +1,7 @@
<!DOCTYPE bac SYSTEM "http://example.org/bac.dtd">
<bac>
- <b/>
- <a/>
+ <b>Let's use a DTD defined entity &bent;</b>
+ <a>Let's use predefined entites & < ></a>
<c/>
</bac>
diff --git a/test/threads/bca.xml b/test/threads/bca.xml
index 4f4f8bb..ce60d01 100644
--- a/test/threads/bca.xml
+++ b/test/threads/bca.xml
@@ -1,7 +1,7 @@
<!DOCTYPE bca SYSTEM "http://example.org/bca.dtd">
<bca>
- <b/>
+ <b>Let's use a DTD defined entity &bent;</b>
<c/>
- <a/>
+ <a>Let's use predefined entites & < ></a>
</bca>
diff --git a/test/threads/cab.xml b/test/threads/cab.xml
index 81f45d0..a1631d0 100644
--- a/test/threads/cab.xml
+++ b/test/threads/cab.xml
@@ -1,7 +1,7 @@
<!DOCTYPE cab SYSTEM "http://example.org/cab.dtd">
<cab>
<c/>
- <a/>
- <b/>
+ <a>Let's use predefined entites & < ></a>
+ <b>Let's use a DTD defined entity &bent;</b>
</cab>
diff --git a/test/threads/cba.xml b/test/threads/cba.xml
index 5bbd570..78708e4 100644
--- a/test/threads/cba.xml
+++ b/test/threads/cba.xml
@@ -1,7 +1,7 @@
<!DOCTYPE cba SYSTEM "http://example.org/cba.dtd">
<cba>
<c/>
- <b/>
- <a/>
+ <b>Let's use a DTD defined entity &bent;</b>
+ <a>Let's use predefined entites & < ></a>
</cba>
diff --git a/testThreads.c b/testThreads.c
index 310a239..8424d31 100644
--- a/testThreads.c
+++ b/testThreads.c
@@ -90,7 +90,7 @@
int ret;
xmlInitParser();
- for (repeat = 0;repeat < 10000;repeat++) {
+ for (repeat = 0;repeat < 500;repeat++) {
xmlLoadCatalog(catalog);
for (i = 0; i < num_threads; i++) {
diff --git a/xmllint.c b/xmllint.c
index 7725c43..9958d0a 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -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 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 @@
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 @@
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 @@
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"))) {