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:
}
varsPush(ctxt, NULL);
- xsltApplyOneTemplate(ctxt, ctxt->node, inst->children);
+ xsltApplyOneTemplate(ctxt, ctxt->node, inst->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
ctxt->insert = oldInsert;
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;
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;
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;
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;
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;
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;
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;
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);
}
}
cur = cur->next;
}
- xsltApplyOneTemplate(ctxt, node, template->content);
+ xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
* @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)
* stack and saves
*/
oldInsert = insert = ctxt->insert;
+ if (real) {
+ oldCurrent = ctxt->current;
+ ctxt->current = node;
+ }
/*
* Insert all non-XSLT nodes found in the template
xsltGenericDebug(xsltGenericDebugContext,
"xsltApplyOneTemplate: insert == NULL !\n");
#endif
+ if (real)
+ ctxt->current = oldCurrent;
return;
}
}
} while (cur != NULL);
}
+ if (real)
+ ctxt->current = oldCurrent;
}
/**
#endif
if (doit) {
varsPush(ctxt, NULL);
- xsltApplyOneTemplate(ctxt, ctxt->node, when->children);
+ xsltApplyOneTemplate(ctxt, ctxt->node, when->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
goto done;
}
}
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;
}
#endif
if (doit) {
varsPush(ctxt, NULL);
- xsltApplyOneTemplate(ctxt, node, inst->children);
+ xsltApplyOneTemplate(ctxt, node, inst->children, 0);
xsltFreeStackElemList(varsPop(ctxt));
}
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;
#endif
templPush(ctxt, template);
varsPush(ctxt, NULL);
- xsltApplyOneTemplate(ctxt, node, template->content);
+ xsltApplyOneTemplate(ctxt, node, template->content, 1);
xsltFreeStackElemList(varsPop(ctxt));
templPop(ctxt);
} else {
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;