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:
@@ -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>
|
Mon Feb 19 18:05:47 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* libxslt/numbers.c libxslt/numbersInternals.h libxslt/xslt.c
|
* libxslt/numbers.c libxslt/numbersInternals.h libxslt/xslt.c
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libxslt \
|
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libxslt \
|
||||||
$(LIBXML_CFLAGS) -Wall -ansi
|
$(LIBXML_CFLAGS) $(CFLAGS)
|
||||||
|
|
||||||
lib_LTLIBRARIES = libxslt.la
|
lib_LTLIBRARIES = libxslt.la
|
||||||
|
|
||||||
|
|||||||
@@ -464,13 +464,22 @@ xsltFunctionAvailableFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
xsltCurrentFunction(xmlXPathParserContextPtr ctxt, int nargs){
|
||||||
|
xsltTransformContextPtr tctxt;
|
||||||
|
|
||||||
if (nargs != 0) {
|
if (nargs != 0) {
|
||||||
xsltGenericError(xsltGenericErrorContext,
|
xsltGenericError(xsltGenericErrorContext,
|
||||||
"document() : function uses no argument\n");
|
"document() : function uses no argument\n");
|
||||||
ctxt->error = XPATH_INVALID_ARITY;
|
ctxt->error = XPATH_INVALID_ARITY;
|
||||||
return;
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ xsltEvalTemplateString(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
oldInsert = ctxt->insert;
|
oldInsert = ctxt->insert;
|
||||||
ctxt->insert = insert;
|
ctxt->insert = insert;
|
||||||
|
|
||||||
xsltApplyOneTemplate(ctxt, node, parent->children);
|
xsltApplyOneTemplate(ctxt, node, parent->children, 0);
|
||||||
|
|
||||||
ctxt->insert = oldInsert;
|
ctxt->insert = oldInsert;
|
||||||
|
|
||||||
|
|||||||
@@ -537,7 +537,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
case XML_HTML_DOCUMENT_NODE:
|
case XML_HTML_DOCUMENT_NODE:
|
||||||
case XML_ELEMENT_NODE:
|
case XML_ELEMENT_NODE:
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
|
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -670,7 +670,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
|
xsltApplyOneTemplate(ctxt, ctxt->node, inst->children, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
|
|
||||||
ctxt->insert = oldInsert;
|
ctxt->insert = oldInsert;
|
||||||
@@ -1115,7 +1115,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1148,7 +1148,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1182,7 +1182,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1273,7 +1273,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1307,7 +1307,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1342,7 +1342,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->xpathCtxt->proximityPosition = childno;
|
ctxt->xpathCtxt->proximityPosition = childno;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, cur, template->content);
|
xsltApplyOneTemplate(ctxt, cur, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1377,7 +1377,7 @@ xsltDefaultProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->xpathCtxt->proximityPosition = childno;
|
ctxt->xpathCtxt->proximityPosition = childno;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, cur, template->content);
|
xsltApplyOneTemplate(ctxt, cur, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
@@ -1414,7 +1414,7 @@ xsltApplyImports(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
if (template != NULL) {
|
if (template != NULL) {
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
}
|
}
|
||||||
@@ -1488,7 +1488,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
|
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
@@ -1719,14 +1719,16 @@ error:
|
|||||||
* @ctxt: a XSLT process context
|
* @ctxt: a XSLT process context
|
||||||
* @node: the node in the source tree.
|
* @node: the node in the source tree.
|
||||||
* @list: the template replacement nodelist
|
* @list: the template replacement nodelist
|
||||||
|
* @real: is this a real template processing
|
||||||
*
|
*
|
||||||
* Process the apply-templates node on the source node
|
* Process the apply-templates node on the source node
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
||||||
xmlNodePtr list) {
|
xmlNodePtr list, int real) {
|
||||||
xmlNodePtr cur = NULL, insert, copy = NULL;
|
xmlNodePtr cur = NULL, insert, copy = NULL;
|
||||||
xmlNodePtr oldInsert;
|
xmlNodePtr oldInsert;
|
||||||
|
xmlNodePtr oldCurrent;
|
||||||
xmlAttrPtr attrs;
|
xmlAttrPtr attrs;
|
||||||
|
|
||||||
if (list == NULL)
|
if (list == NULL)
|
||||||
@@ -1746,6 +1748,10 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
* stack and saves
|
* stack and saves
|
||||||
*/
|
*/
|
||||||
oldInsert = insert = ctxt->insert;
|
oldInsert = insert = ctxt->insert;
|
||||||
|
if (real) {
|
||||||
|
oldCurrent = ctxt->current;
|
||||||
|
ctxt->current = node;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert all non-XSLT nodes found in the template
|
* Insert all non-XSLT nodes found in the template
|
||||||
@@ -1760,6 +1766,8 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
xsltGenericDebug(xsltGenericDebugContext,
|
xsltGenericDebug(xsltGenericDebugContext,
|
||||||
"xsltApplyOneTemplate: insert == NULL !\n");
|
"xsltApplyOneTemplate: insert == NULL !\n");
|
||||||
#endif
|
#endif
|
||||||
|
if (real)
|
||||||
|
ctxt->current = oldCurrent;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1918,6 +1926,8 @@ skip_children:
|
|||||||
}
|
}
|
||||||
} while (cur != NULL);
|
} while (cur != NULL);
|
||||||
}
|
}
|
||||||
|
if (real)
|
||||||
|
ctxt->current = oldCurrent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2001,7 +2011,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
#endif
|
#endif
|
||||||
if (doit) {
|
if (doit) {
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, ctxt->node, when->children);
|
xsltApplyOneTemplate(ctxt, ctxt->node, when->children, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@@ -2018,7 +2028,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
}
|
}
|
||||||
if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) {
|
if (IS_XSLT_ELEM(replacement) && (IS_XSLT_NAME(replacement, "otherwise"))) {
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, ctxt->node, replacement->children);
|
xsltApplyOneTemplate(ctxt, ctxt->node, replacement->children, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
replacement = replacement->next;
|
replacement = replacement->next;
|
||||||
}
|
}
|
||||||
@@ -2104,7 +2114,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
#endif
|
#endif
|
||||||
if (doit) {
|
if (doit) {
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, inst->children);
|
xsltApplyOneTemplate(ctxt, node, inst->children, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2198,7 +2208,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr node,
|
|||||||
ctxt->node = list->nodeTab[i];
|
ctxt->node = list->nodeTab[i];
|
||||||
ctxt->xpathCtxt->proximityPosition = i + 1;
|
ctxt->xpathCtxt->proximityPosition = i + 1;
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement);
|
xsltApplyOneTemplate(ctxt, list->nodeTab[i], replacement, 0);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
}
|
}
|
||||||
ctxt->nodeList = oldlist;
|
ctxt->nodeList = oldlist;
|
||||||
@@ -2257,7 +2267,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
#endif
|
#endif
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
} else {
|
} else {
|
||||||
@@ -2273,7 +2283,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr node) {
|
|||||||
ctxt->node = node;
|
ctxt->node = node;
|
||||||
templPush(ctxt, template);
|
templPush(ctxt, template);
|
||||||
varsPush(ctxt, NULL);
|
varsPush(ctxt, NULL);
|
||||||
xsltApplyOneTemplate(ctxt, node, template->content);
|
xsltApplyOneTemplate(ctxt, node, template->content, 1);
|
||||||
xsltFreeStackElemList(varsPop(ctxt));
|
xsltFreeStackElemList(varsPop(ctxt));
|
||||||
templPop(ctxt);
|
templPop(ctxt);
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ xmlDocPtr xsltApplyStylesheet (xsltStylesheetPtr style,
|
|||||||
xmlDocPtr doc);
|
xmlDocPtr doc);
|
||||||
void xsltApplyOneTemplate (xsltTransformContextPtr ctxt,
|
void xsltApplyOneTemplate (xsltTransformContextPtr ctxt,
|
||||||
xmlNodePtr node,
|
xmlNodePtr node,
|
||||||
xmlNodePtr list);
|
xmlNodePtr list,
|
||||||
|
int real);
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ xsltEvalVariables(xsltTransformContextPtr ctxt, xsltStackElemPtr elem) {
|
|||||||
oldNode = ctxt->node;
|
oldNode = ctxt->node;
|
||||||
ctxt->insert = container;
|
ctxt->insert = container;
|
||||||
|
|
||||||
xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree);
|
xsltApplyOneTemplate(ctxt, ctxt->node, elem->tree, 0);
|
||||||
|
|
||||||
ctxt->insert = oldInsert;
|
ctxt->insert = oldInsert;
|
||||||
ctxt->node = oldNode;
|
ctxt->node = oldNode;
|
||||||
|
|||||||
@@ -216,8 +216,9 @@ struct _xsltTransformContext {
|
|||||||
xsltDocumentPtr docList; /* the document list */
|
xsltDocumentPtr docList; /* the document list */
|
||||||
|
|
||||||
xsltDocumentPtr document; /* the current document */
|
xsltDocumentPtr document; /* the current document */
|
||||||
xmlNodePtr node; /* the current node */
|
xmlNodePtr node; /* the node being processed */
|
||||||
xmlNodeSetPtr nodeList; /* the current node list */
|
xmlNodeSetPtr nodeList; /* the current node list */
|
||||||
|
xmlNodePtr current; /* the current node */
|
||||||
|
|
||||||
xmlDocPtr output; /* the resulting document */
|
xmlDocPtr output; /* the resulting document */
|
||||||
xmlNodePtr insert; /* the insertion node */
|
xmlNodePtr insert; /* the insertion node */
|
||||||
|
|||||||
Reference in New Issue
Block a user