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

- libxslt/Makefile.am: small cleanup

- libxslt/functions.c libxslt/transform.c libxslt/xsltInternals.h:
  fixed current() I hope
Daniel
This commit is contained in:
Daniel Veillard
2001-02-19 18:46:01 +00:00
parent 15914df012
commit e0dfbada8a
8 changed files with 51 additions and 24 deletions

View File

@@ -1,3 +1,9 @@
Mon Feb 19 19:34:59 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/Makefile.am: small cleanup
* libxslt/functions.c libxslt/transform.c libxslt/xsltInternals.h:
fixed current() I hope
Mon Feb 19 18:05:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* libxslt/numbers.c libxslt/numbersInternals.h libxslt/xslt.c

View File

@@ -1,5 +1,5 @@
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libxslt \
$(LIBXML_CFLAGS) -Wall -ansi
$(LIBXML_CFLAGS) $(CFLAGS)
lib_LTLIBRARIES = libxslt.la

View File

@@ -464,13 +464,22 @@ xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
*/
void
xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
xsltTransformContextPtr tctxt;
if (nargs != 0) {
xsltGenericError(xsltGenericErrorContext,
"document() : function uses no argument\n");
ctxt->error = XPATH_INVALID_ARITY;
return;
}
valuePush(ctxt, xmlXPathNewNodeSet(ctxt->context->node));
tctxt = (xsltTransformContextPtr) ctxt->context->extra;
if (tctxt == NULL) {
xsltGenericError(xsltGenericErrorContext,
"current() : internal error tctxt == NULL\n");
valuePush(ctxt, xmlXPathNewNodeSet(NULL));
} else {
valuePush(ctxt, xmlXPathNewNodeSet(tctxt->current));
}
}
/**

View File

@@ -163,7 +163,7 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldInsert = ctxt->insert;
ctxt->insert = insert;
xsltApplyOneTemplate(ctxt, node, parent->children);
xsltApplyOneTemplate(ctxt, node, parent->children, 0);
ctxt->insert = oldInsert;

View File

@@ -537,7 +537,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
case XML_HTML_DOCUMENT_NODE:
case XML_ELEMENT_NODE:
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
break;
default:
@@ -670,7 +670,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
ctxt->insert = oldInsert;
@@ -1115,7 +1115,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1148,7 +1148,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1182,7 +1182,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1273,7 +1273,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1307,7 +1307,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1342,7 +1342,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->xpathCtxt->proximityPosition = childno;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, cur, template->content);
xsltApplyOneTemplate(ctxt, cur, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1377,7 +1377,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->xpathCtxt->proximityPosition = childno;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, cur, template->content);
xsltApplyOneTemplate(ctxt, cur, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;
@@ -1414,7 +1414,7 @@ xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (template != NULL) {
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
}
@@ -1488,7 +1488,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
cur = cur->next;
}
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
@@ -1719,14 +1719,16 @@ error:
* @ctxt: a XSLT process context
* @node: the node in the source tree.
* @list: the template replacement nodelist
* @real: is this a real template processing
*
* Process the apply-templates node on the source node
*/
void
xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr list) {
xmlNodePtr list, int real) {
xmlNodePtr cur = NULL, insert, copy = NULL;
xmlNodePtr oldInsert;
xmlNodePtr oldCurrent;
xmlAttrPtr attrs;
if (list == NULL)
@@ -1746,6 +1748,10 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
* stack and saves
*/
oldInsert = insert = ctxt->insert;
if (real) {
oldCurrent = ctxt->current;
ctxt->current = node;
}
/*
* Insert all non-XSLT nodes found in the template
@@ -1760,6 +1766,8 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplyOneTemplate: insert == NULL !\n");
#endif
if (real)
ctxt->current = oldCurrent;
return;
}
@@ -1918,6 +1926,8 @@ skip_children:
}
} while (cur != NULL);
}
if (real)
ctxt->current = oldCurrent;
}
/**
@@ -2001,7 +2011,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
#endif
if (doit) {
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, ctxt->node, when->children);
xsltApplyOneTemplate(ctxt, ctxt->node, when->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
goto done;
}
@@ -2018,7 +2028,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) {
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, ctxt->node, replacement->children);
xsltApplyOneTemplate(ctxt, ctxt->node, replacement->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
replacement = replacement->next;
}
@@ -2104,7 +2114,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
#endif
if (doit) {
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, inst->children);
xsltApplyOneTemplate(ctxt, node, inst->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
}
@@ -2198,7 +2208,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->node = list->nodeTab[i];
ctxt->xpathCtxt->proximityPosition = i + 1;
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement);
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement, 0);
xsltFreeStackElemList(varsPop(ctxt));
}
ctxt->nodeList = oldlist;
@@ -2257,7 +2267,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
#endif
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
} else {
@@ -2273,7 +2283,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
ctxt->node = node;
templPush(ctxt, template);
varsPush(ctxt, NULL);
xsltApplyOneTemplate(ctxt, node, template->content);
xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
ctxt->node = oldNode;

View File

@@ -23,7 +23,8 @@ xmlDocPtr xsltApplyStylesheet (xsltStylesheetPtr style,
xmlDocPtr doc);
void xsltApplyOneTemplate (xsltTransformContextPtr ctxt,
xmlNodePtr node,
xmlNodePtr list);
xmlNodePtr list,
int real);
#ifdef __cplusplus
}
#endif

View File

@@ -288,7 +288,7 @@ xsltEvalVariables(xsltTransformContextPtr ctxt, xsltStackElemPtr elem) {
oldNode = ctxt->node;
ctxt->insert = container;
xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree);
xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, 0);
ctxt->insert = oldInsert;
ctxt->node = oldNode;

View File

@@ -216,8 +216,9 @@ struct _xsltTransformContext {
xsltDocumentPtr docList; /* the document list */
xsltDocumentPtr document; /* the current document */
xmlNodePtr node; /* the current node */
xmlNodePtr node; /* the node being processed */
xmlNodeSetPtr nodeList; /* the current node list */
xmlNodePtr current; /* the current node */
xmlDocPtr output; /* the resulting document */
xmlNodePtr insert; /* the insertion node */