1
0
mirror of https://gitlab.gnome.org/GNOME/libxslt synced 2025-11-08 11:02:18 +03:00

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
This commit is contained in:
Daniel Veillard
2001-01-21 11:07:02 +00:00
parent 007037dd75
commit 935ed1d25f
10 changed files with 79 additions and 30 deletions

View File

@@ -1,3 +1,14 @@
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> Sat Jan 20 23:35:07 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/Makefile.am libxslt/template.[ch]: added a template * libxslt/Makefile.am libxslt/template.[ch]: added a template

View File

@@ -24,7 +24,7 @@ xsltConf.sh: xsltConf.sh.in Makefile
< $(srcdir)/xsltConf.sh.in > xsltConf.tmp \ < $(srcdir)/xsltConf.sh.in > xsltConf.tmp \
&& mv xsltConf.tmp xsltConf.sh && mv xsltConf.tmp xsltConf.sh
test: test tests:
@(cd tests ; make test) @(cd tests ; make test)

View File

@@ -202,8 +202,11 @@ xsltAttrTemplateProcess(xsltTransformContextPtr ctxt, xmlNodePtr target,
xmlChar *out; xmlChar *out;
if (in != NULL) { if (in != NULL) {
xmlNodePtr child;
out = xsltAttrTemplateValueProcess(ctxt, in); out = xsltAttrTemplateValueProcess(ctxt, in);
ret->children = xmlNewDocText(ctxt->output, out); child = xmlNewDocText(ctxt->output, out);
xmlAddChild((xmlNodePtr) ret, child);
xmlFree(out); xmlFree(out);
xmlFree(in); xmlFree(in);
} else } else
@@ -233,12 +236,16 @@ xsltAttrListTemplateProcess(xsltTransformContextPtr ctxt,
while (cur != NULL) { while (cur != NULL) {
q = xsltAttrTemplateProcess(ctxt, target, cur); q = xsltAttrTemplateProcess(ctxt, target, cur);
if (p == NULL) { if (q != NULL) {
ret = p = q; q->parent = target;
} else { q->doc = ctxt->output;
p->next = q; if (p == NULL) {
q->prev = p; ret = p = q;
p = q; } else {
p->next = q;
q->prev = p;
p = q;
}
} }
cur = cur->next; cur = cur->next;
} }

View File

@@ -294,7 +294,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
value = xmlNodeListGetString(inst->doc, inst->children, 1); value = xmlNodeListGetString(inst->doc, inst->children, 1);
if (value == NULL) { if (value == NULL) {
if (ns) { if (ns) {
#if LIBXML_VERSION > 202111 #if LIBXML_VERSION > 20211
attr = xmlSetNsProp(ctxt->insert, ncname, ns->href, attr = xmlSetNsProp(ctxt->insert, ncname, ns->href,
(const xmlChar *)""); (const xmlChar *)"");
#else #else
@@ -316,6 +316,7 @@ xsltAttribute(xsltTransformContextPtr ctxt, xmlNodePtr node,
#endif #endif
} else } else
attr = xmlSetProp(ctxt->insert, ncname, value); attr = xmlSetProp(ctxt->insert, ncname, value);
} }
error: error:

View File

@@ -866,7 +866,11 @@ xsltParseStylesheetDoc(xmlDocPtr doc) {
"xsltParseStylesheetDoc : document is stylesheet\n"); "xsltParseStylesheetDoc : document is stylesheet\n");
#endif #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); xmlFree(prop);
/* /*

View File

@@ -14,6 +14,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdarg.h> #include <stdarg.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlmemory.h> #include <libxml/xmlmemory.h>
#include <libxml/tree.h> #include <libxml/tree.h>
#include <libxml/xmlerror.h> #include <libxml/xmlerror.h>
@@ -198,6 +199,7 @@ int
xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result, xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
xsltStylesheetPtr style) { xsltStylesheetPtr style) {
const xmlChar *encoding; const xmlChar *encoding;
xmlNodePtr root;
int base; int base;
if ((buf == NULL) || (result == NULL) || (style == NULL)) 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 */ /* TODO: when outputing and having imported stylesheets, apply cascade */
base = buf->written; base = buf->written;
encoding = style->encoding; encoding = style->encoding;
if (xmlStrEqual(style->method, (const xmlChar *) "html")) { if (style->method == NULL)
TODO /* HTML dump ... */ root = xmlDocGetRootElement(result);
} else if (xmlStrEqual(style->method, (const xmlChar *) "text")) { 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; xmlNodePtr cur;
cur = result->children; cur = result->children;
@@ -258,7 +273,7 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
xmlNodePtr child = result->children; xmlNodePtr child = result->children;
while (child != NULL) { while (child != NULL) {
xmlNodeDumpOutput(buf, result, child, 0, style->indent, xmlNodeDumpOutput(buf, result, child, 0, (style->indent == 1),
(const char *) encoding); (const char *) encoding);
xmlOutputBufferWriteString(buf, "\n"); xmlOutputBufferWriteString(buf, "\n");
child = child->next; child = child->next;

View File

@@ -18,6 +18,6 @@ LDADDS = $(top_builddir)/libxslt/libxslt.la $(LIBXML_LIBS)
#testevents_DEPENDENCIES = $(DEPS) #testevents_DEPENDENCIES = $(DEPS)
#testevents_LDADD = $(LDADDS) #testevents_LDADD = $(LDADDS)
test: $(top_builddir)/libxslt/xsltproc test tests: $(top_builddir)/libxslt/xsltproc
@(cd REC1 ; make test) @(cd REC1 ; make test)
@(cd REC2 ; make test) @(cd REC2 ; make test)

View File

@@ -3,7 +3,7 @@
$(top_builddir)/libxslt/xsltproc: $(top_builddir)/libxslt/xsltproc:
@(cd ../../libxslt ; make xsltproc) @(cd ../../libxslt ; make xsltproc)
test: $(top_builddir)/libxslt/xsltproc test tests: $(top_builddir)/libxslt/xsltproc
@(rm -f .memdump ; touch .memdump) @(rm -f .memdump ; touch .memdump)
@($(top_builddir)/libxslt/xsltproc doc.xsl doc.xml > doc.res ; \ @($(top_builddir)/libxslt/xsltproc doc.xsl doc.xml > doc.res ; \
diff result.xml doc.res ; \ diff result.xml doc.res ; \

View File

@@ -3,7 +3,7 @@
$(top_builddir)/libxslt/xsltproc: $(top_builddir)/libxslt/xsltproc:
@(cd ../../libxslt ; make xsltproc) @(cd ../../libxslt ; make xsltproc)
test: $(top_builddir)/libxslt/xsltproc test tests: $(top_builddir)/libxslt/xsltproc
@(rm -f .memdump ; touch .memdump) @(rm -f .memdump ; touch .memdump)
@($(top_builddir)/libxslt/xsltproc vrml.xsl data.xml > vrml.res ; \ @($(top_builddir)/libxslt/xsltproc vrml.xsl data.xml > vrml.res ; \
diff vrml.xml vrml.res ; \ diff vrml.xml vrml.res ; \
@@ -13,5 +13,9 @@ test: $(top_builddir)/libxslt/xsltproc
diff svg.xml svg.res ; \ diff svg.xml svg.res ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\ grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
rm -f svg.res) 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)

View File

@@ -1,22 +1,29 @@
<html lang="en"> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"><html lang="en">
<head> <head><title>Sales Results By Division</title></head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <body><table border="1">
<title>Sales Results By Division</title>
</head>
<body>
<table border="1">
<tr> <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>
<tr> <tr>
<td><em>North</em></td><td>10</td><td>9</td><td>7</td> <td><em>West</em></td>
<td>6</td>
<td style="color:red">-1.5</td>
<td>2</td>
</tr> </tr>
<tr> <tr>
<td><em>West</em></td><td>6</td><td style="color:red">-1.5</td><td>2</td> <td><em>South</em></td>
<td>4</td>
<td>3</td>
<td>4</td>
</tr> </tr>
<tr> <tr>
<td><em>South</em></td><td>4</td><td>3</td><td>4</td> <td><em>North</em></td>
<td>10</td>
<td>9</td>
<td>7</td>
</tr> </tr>
</table> </table></body>
</body>
</html> </html>