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

Test/debug/patch cycle:

- tests/REC/test-[9-10]*: added more tests
- tests/REC2/html.xml libxslt/xsltutils.c libxslt/transform.c:
  fixed sorting
Daniel
parent b2e013a0d72e
No related branches found
No related tags found
No related merge requests found
Wed Jan 31 21:42:43 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tests/REC/test-[9-10]*: added more tests
* tests/REC2/html.xml libxslt/xsltutils.c libxslt/transform.c:
fixed sorting
Wed Jan 31 19:25:38 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* tests/REC/test-[7-9]*: added more tests
......
......@@ -246,6 +246,7 @@
int number = 0;
int len = 0;
int i;
xmlNodePtr oldNode;
if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
return;
......@@ -307,5 +308,6 @@
}
start = xpathParserCtxt->cur;
oldNode = ctxt->node;
for (i = 0;i < len;i++) {
xpathParserCtxt->cur = start;
......@@ -310,4 +312,4 @@
for (i = 0;i < len;i++) {
xpathParserCtxt->cur = start;
node = ctxt->node = list->nodeTab[i];
ctxt->xpathCtxt->contextSize = len;
ctxt->xpathCtxt->proximityPosition = i + 1;
......@@ -313,5 +315,6 @@
ctxt->xpathCtxt->proximityPosition = i + 1;
valuePush(xpathParserCtxt, xmlXPathNewNodeSet(node));
ctxt->node = list->nodeTab[i];
ctxt->xpathCtxt->node = ctxt->node;
xmlXPathEvalExpr(xpathParserCtxt);
xmlXPathStringFunction(xpathParserCtxt, 1);
if (number)
......@@ -348,6 +351,7 @@
}
}
}
ctxt->node = oldNode;
xsltSortFunction(list, &results[0], descending, number);
......@@ -1094,6 +1098,6 @@
* handle and skip the xsl:sort
*/
replacement = inst->children;
while (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "sort"))) {
if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "sort"))) {
xsltSort(ctxt, node, replacement);
replacement = replacement->next;
......@@ -1098,5 +1102,10 @@
xsltSort(ctxt, node, replacement);
replacement = replacement->next;
while (IS_XSLT_ELEM(replacement) &&
(IS_XSLT_NAME(replacement, "sort"))) {
TODO /* imbricated sorts */
replacement = replacement->next;
}
}
for (i = 0;i < list->nodeNr;i++) {
......
......@@ -236,7 +236,8 @@
if (descending)
tst = !tst;
} else {
tst = xmlStrcmp(results[i]->stringval, results[j]->stringval);
tst = (xmlStrcmp(results[i]->stringval,
results[j]->stringval)) > 0;
if (descending)
tst = !tst;
}
......
<employees>
<employee>
<name>
<given>James</given>
<family>Clark</family>
</name>
</employee>
<employee>
<name>
<given>Daniel</given>
<family>Veillard</family>
</name>
</employee>
<employee>
<name>
<given>Michael</given>
<family>Kay</family>
</name>
</employee>
</employees>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="employees">
<ul>
<xsl:apply-templates select="employee">
<xsl:sort select="name/family"/>
<xsl:sort select="name/given"/>
</xsl:apply-templates>
</ul>
</xsl:template>
<xsl:template match="employee">
<li>
<xsl:value-of select="name/given"/>
<xsl:text> </xsl:text>
<xsl:value-of select="name/family"/>
</li>
</xsl:template>
</xsl:stylesheet>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><body><table><tbody>
<tr>item1</tr>
<tr bgcolor="yellow">item2</tr>
<tr>item3</tr>
<tr bgcolor="yellow">item4</tr>
<tr>item5</tr>
<tr bgcolor="yellow">item6</tr>
</tbody></table></body></html>
<itemlist>
<item>item1</item>
<item>item2</item>
<item>item3</item>
<item>item4</item>
<item>item5</item>
<item>item6</item>
</itemlist>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:strip-space elements="itemlist"/>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="itemlist">
<table>
<tbody>
<xsl:apply-templates/>
</tbody>
</table>
</xsl:template>
<xsl:template match="item">
<tr>
<xsl:if test="position() mod 2 = 0">
<xsl:attribute name="bgcolor">yellow</xsl:attribute>
</xsl:if>
<xsl:apply-templates/>
</tr>
</xsl:template>
</xsl:stylesheet>
......@@ -9,6 +9,12 @@
<th>Bonus</th>
</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>
......@@ -20,11 +26,5 @@
<td>3</td>
<td>4</td>
</tr>
<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