Skip to content
Snippets Groups Projects
Commit a9147c4f0c91 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

More work, cleanups, HTML output:

- 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
Daniel
parent 96ed246c7e7d
No related branches found
No related tags found
No related merge requests found
Sun Jan 21 12:03:16 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* 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 <Daniel.Veillard@imag.fr>
* libxslt/Makefile.am libxslt/template.[ch]: added a template
......
......@@ -24,7 +24,7 @@
< $(srcdir)/xsltConf.sh.in > xsltConf.tmp \
&& mv xsltConf.tmp xsltConf.sh
test:
test tests:
@(cd tests ; make test)
......@@ -202,4 +202,6 @@
xmlChar *out;
if (in != NULL) {
xmlNodePtr child;
out = xsltAttrTemplateValueProcess(ctxt, in);
......@@ -205,5 +207,6 @@
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,6 +236,9 @@
while (cur != NULL) {
q = xsltAttrTemplateProcess(ctxt, target, cur);
if (q != NULL) {
q->parent = target;
q->doc = ctxt->output;
if (p == NULL) {
ret = p = q;
} else {
......@@ -240,6 +246,7 @@
q->prev = p;
p = q;
}
}
cur = cur->next;
}
return(ret);
......
......@@ -294,7 +294,7 @@
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 @@
#endif
} else
attr = xmlSetProp(ctxt->insert, ncname, value);
}
error:
......
......@@ -866,7 +866,11 @@
"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);
/*
......
......@@ -14,6 +14,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/xmlerror.h>
......@@ -198,6 +199,7 @@
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 @@
/* 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 @@
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;
......
......@@ -18,6 +18,6 @@
#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)
......@@ -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 ; \
......
......@@ -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 @@
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)
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Sales Results By Division</title>
</head>
<body>
<table border="1">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html lang="en">
<head><title>Sales Results By Division</title></head>
<body><table border="1">
<tr>
......@@ -8,4 +4,7 @@
<tr>
<th>Division</th><th>Revenue</th><th>Growth</th><th>Bonus</th>
<th>Division</th>
<th>Revenue</th>
<th>Growth</th>
<th>Bonus</th>
</tr>
<tr>
......@@ -10,8 +9,8 @@
</tr>
<tr>
<td><em>North</em></td><td>10</td><td>9</td><td>7</td>
</tr>
<tr>
<td><em>West</em></td><td>6</td><td style="color:red">-1.5</td><td>2</td>
<td><em>West</em></td>
<td>6</td>
<td style="color:red">-1.5</td>
<td>2</td>
</tr>
<tr>
......@@ -16,4 +15,7 @@
</tr>
<tr>
<td><em>South</em></td><td>4</td><td>3</td><td>4</td>
<td><em>South</em></td>
<td>4</td>
<td>3</td>
<td>4</td>
</tr>
......@@ -19,4 +21,9 @@
</tr>
</table>
</body>
<tr>
<td><em>North</em></td>
<td>10</td>
<td>9</td>
<td>7</td>
</tr>
</table></body>
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment