diff --git a/ChangeLog b/ChangeLog index 6c3fe9e6..6a0fb5c8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +Sun Jan 21 12:03:16 CET 2001 Daniel Veillard + + * Makefile.am tests/Makefile.am tests/REC1/Makefile.am + tests/REC2/Makefile.am tests/REC2/html.xml: added tests target + too, added the HTML output test + * libxmls/xsltutils.c: added HTML output + * libxslt/xslt.c: check version on literal result used as templates + * libxslt/transform.c: fixed an error in VERSION number + * libxslt/templates.c: make sure generated nodes have doc and + parent properly set + Sat Jan 20 23:35:07 CET 2001 Daniel Veillard * libxslt/Makefile.am libxslt/template.[ch]: added a template diff --git a/Makefile.am b/Makefile.am index 09ee1097..a85bedd7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,7 +24,7 @@ xsltConf.sh: xsltConf.sh.in Makefile < $(srcdir)/xsltConf.sh.in > xsltConf.tmp \ && mv xsltConf.tmp xsltConf.sh -test: +test tests: @(cd tests ; make test) diff --git a/libxslt/templates.c b/libxslt/templates.c index b24a87f6..c80bc410 100644 --- a/libxslt/templates.c +++ b/libxslt/templates.c @@ -202,8 +202,11 @@ xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target, xmlChar *out; if (in != NULL) { + xmlNodePtr child; + out = xsltAttrTemplateValueProcess(ctxt, in); - ret->children = xmlNewDocText(ctxt->output, out); + child = xmlNewDocText(ctxt->output, out); + xmlAddChild((xmlNodePtr) ret, child); xmlFree(out); xmlFree(in); } else @@ -233,12 +236,16 @@ xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt, while (cur != NULL) { q = xsltAttrTemplateProcess(ctxt, target, cur); - if (p == NULL) { - ret = p = q; - } else { - p->next = q; - q->prev = p; - p = q; + if (q != NULL) { + q->parent = target; + q->doc = ctxt->output; + if (p == NULL) { + ret = p = q; + } else { + p->next = q; + q->prev = p; + p = q; + } } cur = cur->next; } diff --git a/libxslt/transform.c b/libxslt/transform.c index f09032cc..19ed865a 100644 --- a/libxslt/transform.c +++ b/libxslt/transform.c @@ -294,7 +294,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node, value = xmlNodeListGetString(inst->doc, inst->children, 1); if (value == NULL) { if (ns) { -#if LIBXML_VERSION > 202111 +#if LIBXML_VERSION > 20211 attr = xmlSetNsProp(ctxt->insert, ncname, ns->href, (const xmlChar *)""); #else @@ -316,6 +316,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node, #endif } else attr = xmlSetProp(ctxt->insert, ncname, value); + } error: diff --git a/libxslt/xslt.c b/libxslt/xslt.c index 6595a5f9..b6f2e7c5 100644 --- a/libxslt/xslt.c +++ b/libxslt/xslt.c @@ -866,7 +866,11 @@ xsltParseStylesheetDoc(xmlDocPtr doc) { "xsltParseStylesheetDoc : document is stylesheet\n"); #endif - /* TODO: check the version */ + if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) { + xsltGenericError(xsltGenericErrorContext, + "xsl:version: only 1.0 features are supported\n"); + TODO /* set up compatibility when not XSLT 1.0 */ + } xmlFree(prop); /* diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c index 98ee425d..1858d6e5 100644 --- a/libxslt/xsltutils.c +++ b/libxslt/xsltutils.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -198,6 +199,7 @@ int xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltStylesheetPtr style) { const xmlChar *encoding; + xmlNodePtr root; int base; if ((buf == NULL) || (result == NULL) || (style == NULL)) @@ -212,9 +214,22 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, /* TODO: when outputing and having imported stylesheets, apply cascade */ base = buf->written; encoding = style->encoding; - if (xmlStrEqual(style->method, (const xmlChar *) "html")) { - TODO /* HTML dump ... */ - } else if (xmlStrEqual(style->method, (const xmlChar *) "text")) { + if (style->method == NULL) + root = xmlDocGetRootElement(result); + else + root = NULL; + if (((style->method != NULL) && + (xmlStrEqual(style->method, (const xmlChar *) "html"))) || + ((root != NULL) && + (xmlStrEqual(root->name, (const xmlChar *) "html")))){ +#if LIBXML_VERSION > 20211 + htmlDocContentDumpOutput(buf, result, (const char *) encoding); +#else + xsltGenericError(xsltGenericErrorContext, + "HTML output requires libxml version > 2.2.11\n"); +#endif + } else if ((style->method != NULL) && + (xmlStrEqual(style->method, (const xmlChar *) "text"))) { xmlNodePtr cur; cur = result->children; @@ -258,7 +273,7 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xmlNodePtr child = result->children; while (child != NULL) { - xmlNodeDumpOutput(buf, result, child, 0, style->indent, + xmlNodeDumpOutput(buf, result, child, 0, (style->indent == 1), (const char *) encoding); xmlOutputBufferWriteString(buf, "\n"); child = child->next; diff --git a/tests/Makefile.am b/tests/Makefile.am index f682102d..c9911c71 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -18,6 +18,6 @@ LDADDS = $(top_builddir)/libxslt/libxslt.la $(LIBXML_LIBS) #testevents_DEPENDENCIES = $(DEPS) #testevents_LDADD = $(LDADDS) -test: $(top_builddir)/libxslt/xsltproc +test tests: $(top_builddir)/libxslt/xsltproc @(cd REC1 ; make test) @(cd REC2 ; make test) diff --git a/tests/REC1/Makefile.am b/tests/REC1/Makefile.am index a01976aa..333629c0 100644 --- a/tests/REC1/Makefile.am +++ b/tests/REC1/Makefile.am @@ -3,7 +3,7 @@ $(top_builddir)/libxslt/xsltproc: @(cd ../../libxslt ; make xsltproc) -test: $(top_builddir)/libxslt/xsltproc +test tests: $(top_builddir)/libxslt/xsltproc @(rm -f .memdump ; touch .memdump) @($(top_builddir)/libxslt/xsltproc doc.xsl doc.xml > doc.res ; \ diff result.xml doc.res ; \ diff --git a/tests/REC2/Makefile.am b/tests/REC2/Makefile.am index 2a49d690..58c43928 100644 --- a/tests/REC2/Makefile.am +++ b/tests/REC2/Makefile.am @@ -3,7 +3,7 @@ $(top_builddir)/libxslt/xsltproc: @(cd ../../libxslt ; make xsltproc) -test: $(top_builddir)/libxslt/xsltproc +test tests: $(top_builddir)/libxslt/xsltproc @(rm -f .memdump ; touch .memdump) @($(top_builddir)/libxslt/xsltproc vrml.xsl data.xml > vrml.res ; \ diff vrml.xml vrml.res ; \ @@ -13,5 +13,9 @@ test: $(top_builddir)/libxslt/xsltproc diff svg.xml svg.res ; \ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ rm -f svg.res) + @($(top_builddir)/libxslt/xsltproc html.xsl data.xml > html.res ; \ + diff html.xml html.res ; \ + grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ + rm -f html.res) diff --git a/tests/REC2/html.xml b/tests/REC2/html.xml index e62b965a..0ba4c8e0 100644 --- a/tests/REC2/html.xml +++ b/tests/REC2/html.xml @@ -1,22 +1,29 @@ - - - -Sales Results By Division - - - + +Sales Results By Division +
- + + + + - + + + + - + + + + - + + + + -
DivisionRevenueGrowthBonusDivisionRevenueGrowthBonus
North1097West6-1.52
West6-1.52South434
South434North1097
- +