summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@redhat.com>2009-09-17 13:25:46 +0200
committerDaniel Veillard <veillard@redhat.com>2009-09-17 13:25:46 +0200
commit2a8398e6bbef97a47099966d587320d59740665a (patch)
tree77f323352a1722a9c2ba0880026a10bf728906e6
parent3058d809d2621aa1d9e416bd86c0ebb243afd45c (diff)
downloadlibxslt-2a8398e6bbef97a47099966d587320d59740665a.tar.gz
Change how attributes are copied for id and speed
* libxslt/transform.c: change the way we copy attributes, use a function allowing id detection, and avoid an unecessary string generation/free in most cases. Also cleanup a number of space and tabs issues.
-rw-r--r--libxslt/transform.c522
1 files changed, 254 insertions, 268 deletions
diff --git a/libxslt/transform.c b/libxslt/transform.c
index ce0bf434..db2a5042 100644
--- a/libxslt/transform.c
+++ b/libxslt/transform.c
@@ -190,7 +190,7 @@ xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
break;
variable = ctxt->varsTab[ctxt->varsNr - 1];
if (variable->level <= level)
- break;
+ break;
if (variable->level >= 0)
xsltFreeStackElemList(variable);
ctxt->varsNr--;
@@ -205,12 +205,12 @@ xsltLocalVariablePop(xsltTransformContextPtr ctxt, int limitNr, int level)
* xsltTemplateParamsCleanup:
*
* Removes xsl:param and xsl:with-param items from the
- * variable-stack. Only xsl:with-param items are not freed.
+ * variable-stack. Only xsl:with-param items are not freed.
*/
static void
xsltTemplateParamsCleanup(xsltTransformContextPtr ctxt)
{
- xsltStackElemPtr param;
+ xsltStackElemPtr param;
for (; ctxt->varsNr > ctxt->varsBase; ctxt->varsNr--) {
param = ctxt->varsTab[ctxt->varsNr -1];
@@ -218,10 +218,10 @@ xsltTemplateParamsCleanup(xsltTransformContextPtr ctxt)
* Free xsl:param items.
* xsl:with-param items will have a level of -1 or -2.
*/
- if (param->level >= 0) {
+ if (param->level >= 0) {
xsltFreeStackElemList(param);
- }
- }
+ }
+ }
if (ctxt->varsNr > 0)
ctxt->vars = ctxt->varsTab[ctxt->varsNr - 1];
else
@@ -352,7 +352,7 @@ static xsltTransformCachePtr
xsltTransformCacheCreate(void)
{
xsltTransformCachePtr ret;
-
+
ret = (xsltTransformCachePtr) xmlMalloc(sizeof(xsltTransformCache));
if (ret == NULL) {
xsltTransformError(NULL, NULL, NULL,
@@ -365,9 +365,9 @@ xsltTransformCacheCreate(void)
static void
xsltTransformCacheFree(xsltTransformCachePtr cache)
-{
+{
if (cache == NULL)
- return;
+ return;
/*
* Free tree fragments.
*/
@@ -498,7 +498,7 @@ xsltNewTransformContext(xsltStylesheetPtr style, xmlDocPtr doc) {
*/
if (style->extrasNr != 0) {
cur->extrasMax = style->extrasNr + 20;
- cur->extras = (xsltRuntimeExtraPtr)
+ cur->extras = (xsltRuntimeExtraPtr)
xmlMalloc(cur->extrasMax * sizeof(xsltRuntimeExtra));
if (cur->extras == NULL) {
xmlGenericError(xmlGenericErrorContext,
@@ -711,9 +711,9 @@ xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
len = xmlStrlen(string);
if ((ctxt->type == XSLT_OUTPUT_XML) &&
(ctxt->style->cdataSection != NULL) &&
- (target != NULL) &&
+ (target != NULL) &&
(target->type == XML_ELEMENT_NODE) &&
- (((target->ns == NULL) &&
+ (((target->ns == NULL) &&
(xmlHashLookup2(ctxt->style->cdataSection,
target->name, NULL) != NULL)) ||
((target->ns != NULL) &&
@@ -788,7 +788,7 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
if ((cur->type != XML_TEXT_NODE) &&
(cur->type != XML_CDATA_SECTION_NODE))
return(NULL);
- if (cur->content == NULL)
+ if (cur->content == NULL)
return(NULL);
#ifdef WITH_XSLT_DEBUG_PROCESS
@@ -816,10 +816,10 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
}
if ((ctxt->style->cdataSection != NULL) &&
- (ctxt->type == XSLT_OUTPUT_XML) &&
+ (ctxt->type == XSLT_OUTPUT_XML) &&
(target != NULL) &&
(target->type == XML_ELEMENT_NODE) &&
- (((target->ns == NULL) &&
+ (((target->ns == NULL) &&
(xmlHashLookup2(ctxt->style->cdataSection,
target->name, NULL) != NULL)) ||
((target->ns != NULL) &&
@@ -829,8 +829,8 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
/*
* Process "cdata-section-elements".
*/
- /*
- * OPTIMIZE TODO: xsltCopyText() is also used for attribute content.
+ /*
+ * OPTIMIZE TODO: xsltCopyText() is also used for attribute content.
*/
/*
* TODO: Since this doesn't merge adjacent CDATA-section nodes,
@@ -849,7 +849,7 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
} else {
unsigned int len;
- len = xmlStrlen(cur->content);
+ len = xmlStrlen(cur->content);
copy = xmlNewCDataBlock(ctxt->output, cur->content, len);
if (copy == NULL)
goto exit;
@@ -875,20 +875,20 @@ xsltCopyText(xsltTransformContextPtr ctxt, xmlNodePtr target,
} else if ((interned) && (target != NULL) &&
(target->doc != NULL) &&
(target->doc->dict == ctxt->dict))
- {
+ {
/*
* TODO: DO we want to use this also for "text" output?
*/
copy = xmlNewTextLen(NULL, 0);
if (copy == NULL)
- goto exit;
+ goto exit;
if (cur->name == xmlStringTextNoenc)
copy->name = xmlStringTextNoenc;
-
+
/*
* Must confirm that content is in dict (bug 302821)
* TODO: This check should be not needed for text coming
- * from the stylesheets
+ * from the stylesheets
*/
if (xmlDictOwns(ctxt->dict, cur->content))
copy->content = cur->content;
@@ -968,7 +968,7 @@ xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,
"Cannot add an attribute node to a non-element node.\n");
return(NULL);
}
-
+
if (target->children != NULL) {
xsltTransformError(ctxt, NULL, invocNode,
"Attribute nodes must be added before "
@@ -978,7 +978,7 @@ xsltShallowCopyAttr(xsltTransformContextPtr ctxt, xmlNodePtr invocNode,
value = xmlNodeListGetString(attr->doc, attr->children, 1);
if (attr->ns != NULL) {
- xmlNsPtr ns;
+ xmlNsPtr ns;
ns = xsltGetSpecialNamespace(ctxt, invocNode,
attr->ns->href, attr->ns->prefix, target);
@@ -1057,9 +1057,9 @@ xsltCopyAttrListNoOverwrite(xsltTransformContextPtr ctxt,
xmlNodePtr invocNode,
xmlNodePtr target, xmlAttrPtr attr)
{
- xmlAttrPtr last = NULL, copy;
+ xmlAttrPtr copy;
xmlNsPtr origNs = NULL, copyNs = NULL;
- xmlChar *value = NULL;
+ xmlChar *value;
/*
* Don't use xmlCopyProp() here, since it will try to
@@ -1084,36 +1084,23 @@ xsltCopyAttrListNoOverwrite(xsltTransformContextPtr ctxt,
* If attribute has a value, we need to copy it (watching out
* for possible entities)
*/
- if (attr->children)
- value = xmlNodeListGetString(attr->doc, attr->children, 0);
- /*
- * REVISIT: I think xmlNewDocProp() is the only attr function
- * which does not eval if the attr is of type ID. This is good,
- * since we don't need this.
- */
- copy = xmlNewDocProp(target->doc, attr->name, BAD_CAST value);
+ if ((attr->children) && (attr->children->type == XML_TEXT_NODE) &&
+ (attr->children->next == NULL)) {
+ copy = xmlNewNsProp(target, copyNs, attr->name,
+ attr->children->content);
+ } else if (attr->children != NULL) {
+ value = xmlNodeListGetString(attr->doc, attr->children, 1);
+ copy = xmlNewNsProp(target, copyNs, attr->name, BAD_CAST value);
+ xmlFree(value);
+ } else {
+ copy = xmlNewNsProp(target, copyNs, attr->name, NULL);
+ }
+
if (copy == NULL)
return(-1);
- copy->parent = target;
- copy->ns = copyNs;
-
- if (last == NULL) {
- target->properties = copy;
- last = copy;
- } else {
- last->next = copy;
- copy->prev = last;
- last = copy;
- }
- /*
- * OPTIMIZE TODO: How to avoid this intermediate string?
- */
- if (value != NULL) {
- xmlFree(value);
- value = NULL;
- }
+
attr = attr->next;
- }
+ }
return(0);
}
@@ -1191,7 +1178,7 @@ xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
} else {
copy->ns = xsltGetSpecialNamespace(ctxt,
node, node->ns->href, node->ns->prefix, copy);
-
+
}
} else if ((insert->type == XML_ELEMENT_NODE) &&
(insert->ns != NULL))
@@ -1283,7 +1270,7 @@ xsltCopyNamespaceListInternal(xmlNodePtr elem, xmlNsPtr ns) {
/*
* Avoid duplicating namespace declarations on the tree.
*/
- if (elem != NULL) {
+ if (elem != NULL) {
if ((elem->ns != NULL) &&
xmlStrEqual(elem->ns->prefix, ns->prefix) &&
xmlStrEqual(elem->ns->href, ns->href))
@@ -1297,7 +1284,7 @@ xsltCopyNamespaceListInternal(xmlNodePtr elem, xmlNsPtr ns) {
ns = ns->next;
continue;
}
- }
+ }
q = xmlNewNs(elem, ns->href, ns->prefix);
if (p == NULL) {
ret = p = q;
@@ -1305,7 +1292,7 @@ xsltCopyNamespaceListInternal(xmlNodePtr elem, xmlNsPtr ns) {
p->next = q;
p = q;
}
- ns = ns->next;
+ ns = ns->next;
} while (ns != NULL);
return(ret);
}
@@ -1328,35 +1315,34 @@ xsltShallowCopyNsNode(xsltTransformContextPtr ctxt,
xmlNsPtr ns)
{
/*
- * TODO: Contrary to header comments, this is declared as int.
+ * TODO: Contrary to header comments, this is declared as int.
* be modified to return a node pointer, or NULL if any error
*/
xmlNsPtr tmpns;
if ((insert == NULL) || (insert->type != XML_ELEMENT_NODE))
return(NULL);
-
+
if (insert->children != NULL) {
xsltTransformError(ctxt, NULL, invocNode,
"Namespace nodes must be added before "
"any child nodes are added to an element.\n");
return(NULL);
}
- /*
- *
- * BIG NOTE: Xalan-J simply overwrites any ns-decls with
- * an equal prefix. We definitively won't do that.
- *
- * MSXML 4.0 and the .NET ignores ns-decls for which an
- * equal prefix is already in use.
- *
- * Saxon raises an error like:
- * "net.sf.saxon.xpath.DynamicError: Cannot create two namespace
- * nodes with the same name".
- *
- * NOTE: We'll currently follow MSXML here.
- * REVISIT TODO: Check if it's better to follow Saxon here.
- */
+ /*
+ * BIG NOTE: Xalan-J simply overwrites any ns-decls with
+ * an equal prefix. We definitively won't do that.
+ *
+ * MSXML 4.0 and the .NET ignores ns-decls for which an
+ * equal prefix is already in use.
+ *
+ * Saxon raises an error like:
+ * "net.sf.saxon.xpath.DynamicError: Cannot create two namespace
+ * nodes with the same name".
+ *
+ * NOTE: We'll currently follow MSXML here.
+ * REVISIT TODO: Check if it's better to follow Saxon here.
+ */
if (ns->prefix == NULL) {
/*
* If we are adding ns-nodes to an element using e.g.
@@ -1380,7 +1366,7 @@ xsltShallowCopyNsNode(xsltTransformContextPtr ctxt,
if (insert->nsDef != NULL) {
tmpns = insert->nsDef;
do {
- if ((tmpns->prefix == NULL) == (ns->prefix == NULL)) {
+ if ((tmpns->prefix == NULL) == (ns->prefix == NULL)) {
if ((tmpns->prefix == ns->prefix) ||
xmlStrEqual(tmpns->prefix, ns->prefix))
{
@@ -1467,7 +1453,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
case XML_NAMESPACE_DECL:
return((xmlNodePtr) xsltShallowCopyNsNode(ctxt, invocNode,
insert, (xmlNsPtr) node));
-
+
case XML_DOCUMENT_TYPE_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_NOTATION_NODE:
@@ -1478,7 +1464,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
return(NULL);
- }
+ }
if (XSLT_IS_RES_TREE_FRAG(node)) {
if (node->children != NULL)
copy = xsltCopyTreeList(ctxt, invocNode,
@@ -1498,7 +1484,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
return(insert->last);
copy->next = NULL;
- if (node->type == XML_ELEMENT_NODE) {
+ if (node->type == XML_ELEMENT_NODE) {
/*
* Copy in-scope namespace nodes.
*
@@ -1517,7 +1503,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
(node->parent->type != XML_HTML_DOCUMENT_NODE))
{
xmlNsPtr *nsList, *curns, ns;
-
+
/*
* If this is a top-most element in a tree to be
* copied, then we need to ensure that all in-scope
@@ -1525,7 +1511,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
* tree, it is sufficient to reconcile only the ns-decls
* (node->nsDef entries).
*/
-
+
nsList = xmlGetNsList(node->doc, node);
if (nsList != NULL) {
curns = nsList;
@@ -1536,7 +1522,7 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
*/
ns = xmlSearchNs(insert->doc, insert,
(*curns)->prefix);
-
+
if ((ns == NULL) ||
(! xmlStrEqual(ns->href, (*curns)->href)))
{
@@ -1569,9 +1555,9 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
} while (*curns != NULL);
xmlFree(nsList);
}
- } else if (node->nsDef != NULL) {
+ } else if (node->nsDef != NULL) {
/*
- * Copy over all namespace declaration attributes.
+ * Copy over all namespace declaration attributes.
*/
if (node->nsDef != NULL) {
if (isLRE)
@@ -1644,7 +1630,7 @@ xsltCopyTree(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr insert, int literal)
{
return(xsltCopyTreeInternal(ctxt, node, node, insert, literal, 0));
-
+
}
/************************************************************************
@@ -1669,7 +1655,7 @@ xsltApplyFallbacks(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlNodePtr child;
int ret = 0;
-
+
if ((ctxt == NULL) || (node == NULL) || (inst == NULL) ||
(inst->children == NULL))
return(0);
@@ -1971,7 +1957,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
{
xsltTemplatePtr templ;
xmlNodePtr oldNode;
-
+
templ = xsltGetTemplate(ctxt, contextNode, NULL);
/*
* If no template is found, apply the default rule.
@@ -2001,7 +1987,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
}
if (contextNode->type == XML_ATTRIBUTE_NODE) {
- xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
+ xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
/*
* Set the "current template rule".
*/
@@ -2016,7 +2002,7 @@ xsltProcessOneNode(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
ctxt->currentTemplateRule = oldCurTempRule;
} else {
- xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
+ xsltTemplatePtr oldCurTempRule = ctxt->currentTemplateRule;
/*
* Set the "current template rule".
*/
@@ -2046,7 +2032,7 @@ xsltDebuggerStartSequenceConstructor(xsltTransformContextPtr ctxt,
xsltTemplatePtr templ,
int *addCallResult)
{
- xmlNodePtr debugedNode = NULL;
+ xmlNodePtr debugedNode = NULL;
if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
if (templ) {
@@ -2129,7 +2115,7 @@ static void
xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
{
xmlDocPtr cur = ctxt->localRVT, tmp;
-
+
while ((cur != NULL) && (cur != base)) {
if (cur->psvi == (void *) ((long) 1)) {
cur = (xmlDocPtr) cur->next;
@@ -2165,7 +2151,7 @@ xsltReleaseLocalRVTs(xsltTransformContextPtr ctxt, xmlDocPtr base)
* @templ: the compiled xsl:template (optional)
*
* Processes a sequence constructor.
- *
+ *
* NOTE: ctxt->currentTemplateRule was introduced to reflect the
* semantics of "current template rule". I.e. the field ctxt->templ
* is not intended to reflect this, thus always pushed onto the
@@ -2193,7 +2179,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
if (ctxt == NULL)
return;
-#ifdef WITH_DEBUGGER
+#ifdef WITH_DEBUGGER
if (ctxt->debugStatus != XSLT_DEBUG_NONE) {
debuggedNode =
xsltDebuggerStartSequenceConstructor(ctxt, contextNode,
@@ -2268,7 +2254,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
if (IS_XSLT_ELEM_FAST(cur) && IS_XSLT_NAME(cur, "message")) {
xsltMessage(ctxt, contextNode, cur);
goto skip_children;
- }
+ }
/*
* Something really went wrong:
*/
@@ -2298,7 +2284,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
* OLD: if ((copy = xsltShallowCopyElem(ctxt, cur, insert))
* == NULL)
* goto error;
- */
+ */
copy = xmlDocCopyNode(cur, insert->doc, 0);
if (copy == NULL) {
xsltTransformError(ctxt, NULL, cur,
@@ -2325,13 +2311,13 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
* Avoid generating redundant namespace
* declarations; thus lookup if there is already
* such a ns-decl in the result.
- */
+ */
ns = xmlSearchNs(copy->doc, copy, effNs->prefix);
if ((ns != NULL) &&
(xmlStrEqual(ns->href, effNs->nsName)))
{
effNs = effNs->next;
- continue;
+ continue;
}
ns = xmlNewNs(copy, effNs->nsName, effNs->prefix);
if (ns == NULL) {
@@ -2342,7 +2328,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
"declaration.\n");
goto error;
}
-
+
if (lastns == NULL)
copy->nsDef = ns;
else
@@ -2351,7 +2337,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
effNs = effNs->next;
}
-
+
}
/*
* NOTE that we don't need to apply ns-alising: this was
@@ -2362,9 +2348,9 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
* If there's no such ns-decl in the result tree,
* then xsltGetSpecialNamespace() will
* create a ns-decl on the copied node.
- */
+ */
copy->ns = xsltGetSpecialNamespace(ctxt, cur,
- cur->ns->href, cur->ns->prefix, copy);
+ cur->ns->href, cur->ns->prefix, copy);
} else {
/*
* Undeclare the default namespace if needed.
@@ -2378,7 +2364,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
* REVISIT: This might result in massive
* generation of ns-decls if nodes in a default
* namespaces are mixed with nodes in no namespace.
- *
+ *
*/
if (copy->nsDef ||
((insert != NULL) &&
@@ -2409,14 +2395,14 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
/*
* We hit an unknown XSLT element.
* Try to apply one of the fallback cases.
- */
+ */
ctxt->insert = insert;
if (!xsltApplyFallbacks(ctxt, contextNode, cur)) {
xsltTransformError(ctxt, NULL, cur,
"The is no fallback behaviour defined for "
"the unknown XSLT element '%s'.\n",
cur->name);
- }
+ }
ctxt->insert = oldInsert;
} else if (info->func != NULL) {
/*
@@ -2434,11 +2420,11 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
ctxt->insert = oldInsert;
- } else if (info->type == XSLT_FUNC_VARIABLE) {
+ } else if (info->type == XSLT_FUNC_VARIABLE) {
xsltStackElemPtr tmpvar = ctxt->vars;
-
+
xsltParseStylesheetVariable(ctxt, cur);
-
+
if (tmpvar != ctxt->vars) {
/*
* TODO: Using a @tmpvar is an annoying workaround, but
@@ -2455,7 +2441,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
xsltMessage(ctxt, contextNode, cur);
} else {
xsltTransformError(ctxt, NULL, cur,
- "Unexpected XSLT element '%s'.\n", cur->name);
+ "Unexpected XSLT element '%s'.\n", cur->name);
}
goto skip_children;
@@ -2464,7 +2450,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
/*
* Extension intructions (elements)
* --------------------------------------------------------
- */
+ */
if (cur->psvi == xsltExtMarker) {
/*
* The xsltExtMarker was set during the compilation
@@ -2478,7 +2464,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
xsltExtElementLookup(ctxt, cur->name, cur->ns->href);
} else
func = ((xsltElemPreCompPtr) cur->psvi)->func;
-
+
if (func == NULL) {
/*
* No handler available.
@@ -2495,8 +2481,8 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
xsltTransformError(ctxt, NULL, cur,
"Unknown extension instruction '{%s}%s'.\n",
cur->ns->href, cur->name);
- }
- ctxt->insert = oldInsert;
+ }
+ ctxt->insert = oldInsert;
} else {
/*
* Execute the handler-callback.
@@ -2505,7 +2491,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
"xsltApplySequenceConstructor: extension construct %s\n",
cur->name));
-#endif
+#endif
ctxt->insert = insert;
/*
* We need the fragment base for extension instructions
@@ -2547,7 +2533,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
}
#endif
if (xsltCopyText(ctxt, insert, cur, ctxt->internalized) == NULL)
- goto error;
+ goto error;
}
#else /* XSLT_REFACTORED */
@@ -2561,7 +2547,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
if (info == NULL) {
if (IS_XSLT_NAME(cur, "message")) {
xsltMessage(ctxt, contextNode, cur);
- } else {
+ } else {
/*
* That's an error try to apply one of the fallback cases
*/
@@ -2574,7 +2560,7 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
ctxt->insert = oldInsert;
}
goto skip_children;
- }
+ }
if (info->func != NULL) {
oldCurInst = ctxt->inst;
@@ -2599,14 +2585,14 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
if (IS_XSLT_NAME(cur, "variable")) {
xsltStackElemPtr tmpvar = ctxt->vars;
-
+
oldCurInst = ctxt->inst;
ctxt->inst = cur;
xsltParseStylesheetVariable(ctxt, cur);
ctxt->inst = oldCurInst;
-
+
if (tmpvar != ctxt->vars) {
/*
* TODO: Using a @tmpvar is an annoying workaround, but
@@ -2730,11 +2716,11 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
ctxt->inst = cur;
if ((copy = xsltShallowCopyElem(ctxt, cur, insert, 1)) == NULL)
- goto error;
+ goto error;
/*
* Add extra namespaces inherited from the current template
* if we are in the first level children and this is a
- * "real" template.
+ * "real" template.
*/
if ((templ != NULL) && (oldInsert == insert) &&
(ctxt->templ != NULL) && (ctxt->templ->inheritedNs != NULL)) {
@@ -2744,8 +2730,8 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
for (i = 0; i < ctxt->templ->inheritedNsNr; i++) {
const xmlChar *URI = NULL;
xsltStylesheetPtr style;
- ns = ctxt->templ->inheritedNs[i];
-
+ ns = ctxt->templ->inheritedNs[i];
+
/* Note that the XSLT namespace was already excluded
* in xsltGetInheritedNsList().
*/
@@ -2756,11 +2742,11 @@ xsltApplySequenceConstructor(xsltTransformContextPtr ctxt,
style = ctxt->style;
while (style != NULL) {
if (style->nsAliases != NULL)
- URI = (const xmlChar *)
+ URI = (const xmlChar *)
xmlHashLookup(style->nsAliases, ns->href);
if (URI != NULL)
break;
-
+
style = xsltNextImport(style);
}
if (URI == UNDEFINED_DEFAULT_NS)
@@ -2828,7 +2814,7 @@ skip_children:
* Pop variables/params (xsl:variable and xsl:param).
*/
if ((ctxt->varsNr > oldVarsNr) && (ctxt->vars->level > level)) {
- xsltLocalVariablePop(ctxt, oldVarsNr, level);
+ xsltLocalVariablePop(ctxt, oldVarsNr, level);
}
insert = insert->parent;
@@ -2850,12 +2836,12 @@ error:
* In case of errors: pop remaining variables.
*/
if (ctxt->varsNr > oldVarsNr)
- xsltLocalVariablePop(ctxt, oldVarsNr, -1);
+ xsltLocalVariablePop(ctxt, oldVarsNr, -1);
ctxt->node = oldContextNode;
ctxt->inst = oldInst;
ctxt->insert = oldInsert;
-
+
#ifdef WITH_DEBUGGER
if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
xslDropCall();
@@ -2900,10 +2886,10 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
#ifdef WITH_DEBUGGER
int addCallResult = 0;
-#endif
+#endif
if (ctxt == NULL)
- return;
+ return;
if (templ == NULL) {
xsltTransformError(ctxt, NULL, list,
"xsltApplyXSLTTemplate: Bad arguments; @templ is mandatory.\n");
@@ -2939,17 +2925,17 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
xsltDebug(ctxt, contextNode, list, NULL);
return;
}
-
+
oldUserFragmentTop = ctxt->tmpRVT;
ctxt->tmpRVT = NULL;
oldLocalFragmentTop = ctxt->localRVT;
-
+
/*
* Initiate a distinct scope of local params/variables.
*/
oldVarsBase = ctxt->varsBase;
ctxt->varsBase = ctxt->varsNr;
-
+
ctxt->node = contextNode;
if (ctxt->profile) {
templ->nbCalls++;
@@ -2960,7 +2946,7 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
* Push the xsl:template declaration onto the stack.
*/
templPush(ctxt, templ);
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
if (templ->name != NULL)
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATE,xsltGenericDebug(xsltGenericDebugContext,
@@ -2992,7 +2978,7 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
#else
iparam = (xsltStylePreCompPtr) cur->psvi;
#endif
-
+
/*
* Substitute xsl:param for a given xsl:with-param.
* Since the XPath expression will reference the params/vars
@@ -3010,7 +2996,7 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
{
/*
* Push the caller-parameter.
- */
+ */
xsltLocalVariablePush(ctxt, tmpParam, -1);
break;
}
@@ -3028,20 +3014,20 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
xsltParseStylesheetParam(ctxt, cur);
}
cur = cur->next;
- } while (cur != NULL);
+ } while (cur != NULL);
/*
* Process the sequence constructor.
*/
xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
-
+
/*
* Remove remaining xsl:param and xsl:with-param items from
* the stack. Don't free xsl:with-param items.
*/
if (ctxt->varsNr > ctxt->varsBase)
- xsltTemplateParamsCleanup(ctxt);
+ xsltTemplateParamsCleanup(ctxt);
ctxt->varsBase = oldVarsBase;
-
+
/*
* Clean up remaining local tree fragments.
* This also frees fragments which are the result of
@@ -3071,7 +3057,7 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
* Release user-created fragments stored in the scope
* of xsl:template. Note that this mechanism is deprecated:
* user code should now use xsltRegisterLocalRVT() instead
- * of the obsolete xsltRegisterTmpRVT().
+ * of the obsolete xsltRegisterTmpRVT().
*/
if (ctxt->tmpRVT) {
xmlDocPtr curdoc = ctxt->tmpRVT, tmp;
@@ -3080,17 +3066,17 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
tmp = curdoc;
curdoc = (xmlDocPtr) curdoc->next;
xsltReleaseRVT(ctxt, tmp);
- }
+ }
}
- ctxt->tmpRVT = oldUserFragmentTop;
-
+ ctxt->tmpRVT = oldUserFragmentTop;
+
/*
* Pop the xsl:template declaration from the stack.
*/
- templPop(ctxt);
+ templPop(ctxt);
if (ctxt->profile) {
long spent, child, total, end;
-
+
end = xsltTimestamp();
child = profPop(ctxt);
total = end - start;
@@ -3103,12 +3089,12 @@ xsltApplyXSLTTemplate(xsltTransformContextPtr ctxt,
xsltCalibrateAdjust(spent);
spent = 0;
}
-
+
templ->time += spent;
if (ctxt->profNr > 0)
ctxt->profTab[ctxt->profNr - 1] += total;
}
-
+
#ifdef WITH_DEBUGGER
if ((ctxt->debugStatus != XSLT_DEBUG_NONE) && (addCallResult)) {
xslDropCall();
@@ -3179,7 +3165,7 @@ xsltApplyOneTemplate(xsltTransformContextPtr ctxt,
*/
xsltLocalVariablePop(ctxt, oldVarsNr, -2);
} else
- xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
+ xsltApplySequenceConstructor(ctxt, contextNode, list, templ);
}
/************************************************************************
@@ -3240,7 +3226,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
URL = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *) "file",
XSLT_SAXON_NAMESPACE);
-
+
if (URL == NULL)
URL = xsltEvalAttrValueTemplate(ctxt, inst,
(const xmlChar *) "href",
@@ -3262,7 +3248,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
* Trying to handle bug #59212
* The value of the "select" attribute is an
* XPath expression.
- * (see http://xml.apache.org/xalan-j/extensionslib.html#redirect)
+ * (see http://xml.apache.org/xalan-j/extensionslib.html#redirect)
*/
cmp = xmlXPathCompile(URL);
val = xsltEvalXPathString(ctxt, cmp);
@@ -3715,7 +3701,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltStylePreCompPtr comp = castedComp;
#endif
xmlNodePtr copy, oldInsert;
-
+
oldInsert = ctxt->insert;
if (ctxt->insert != NULL) {
switch (node->type) {
@@ -3746,7 +3732,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
* REMOVED:
* if (xmlStrEqual(node->name, BAD_CAST " fake node libxslt"))
* return;
- */
+ */
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
@@ -3769,7 +3755,7 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
* OPTIMIZE TODO: Can we set the value/children of the
* attribute without an intermediate copy of the string value?
*/
- xsltShallowCopyAttr(ctxt, inst, ctxt->insert, (xmlAttrPtr) node);
+ xsltShallowCopyAttr(ctxt, inst, ctxt->insert, (xmlAttrPtr) node);
break;
}
case XML_PI_NODE:
@@ -3793,8 +3779,8 @@ xsltCopy(xsltTransformContextPtr ctxt, xmlNodePtr node,
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_COPY,xsltGenericDebug(xsltGenericDebugContext,
"xsltCopy: namespace declaration\n"));
-#endif
- xsltShallowCopyNsNode(ctxt, inst, ctxt->insert, (xmlNsPtr)node);
+#endif
+ xsltShallowCopyNsNode(ctxt, inst, ctxt->insert, (xmlNsPtr)node);
break;
default:
break;
@@ -3870,14 +3856,14 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltStylePreCompPtr comp = castedComp;
#endif
xmlChar *prop = NULL;
- const xmlChar *name, *prefix = NULL, *nsName = NULL;
+ const xmlChar *name, *prefix = NULL, *nsName = NULL;
xmlNodePtr copy;
xmlNodePtr oldInsert;
if (ctxt->insert == NULL)
return;
- /*
+ /*
* A comp->has_name == 0 indicates that we need to skip this instruction,
* since it was evaluated to be invalid already during compilation.
*/
@@ -3921,11 +3907,11 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
#ifdef XSLT_REFACTORED
prefix = comp->nsPrefix;
name = comp->name;
-#else
+#else
name = xsltSplitQName(ctxt->dict, comp->name, &prefix);
#endif
}
-
+
/*
* Create the new element
*/
@@ -3939,13 +3925,13 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
"xsl:element : creation of %s failed\n", name);
return;
}
- xmlAddChild(ctxt->insert, copy);
+ xmlAddChild(ctxt->insert, copy);
/*
* Namespace
* ---------
*/
- if (comp->has_ns) {
+ if (comp->has_ns) {
if (comp->ns != NULL) {
/*
* No AVT; just plain text for the namespace name.
@@ -3959,7 +3945,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
*/
/* TODO: check attr acquisition wrt to the XSLT namespace */
tmpNsName = xsltEvalAttrValueTemplate(ctxt, inst,
- (const xmlChar *) "namespace", XSLT_NAMESPACE);
+ (const xmlChar *) "namespace", XSLT_NAMESPACE);
/*
* SPEC XSLT 1.0:
* "If the string is empty, then the expanded-name of the
@@ -3967,8 +3953,8 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
*/
if ((tmpNsName != NULL) && (tmpNsName[0] != 0))
nsName = xmlDictLookup(ctxt->dict, BAD_CAST tmpNsName, -1);
- xmlFree(tmpNsName);
- };
+ xmlFree(tmpNsName);
+ };
} else {
xmlNsPtr ns;
/*
@@ -3977,7 +3963,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
* expanded into an expanded-name using the namespace declarations
* in effect for the xsl:element element, including any default
* namespace declaration.
- */
+ */
ns = xmlSearchNs(inst->doc, inst, prefix);
if (ns == NULL) {
/*
@@ -3992,7 +3978,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
"specified by the instruction itself.\n", prefix, name);
}
} else
- nsName = ns->href;
+ nsName = ns->href;
}
/*
* Find/create a matching ns-decl in the result tree.
@@ -4037,7 +4023,7 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
error:
ctxt->insert = oldInsert;
- return;
+ return;
}
@@ -4056,15 +4042,15 @@ xsltComment(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlChar *value = NULL;
xmlNodePtr commentNode;
int len;
-
+
value = xsltEvalTemplateString(ctxt, node, inst);
/* TODO: use or generate the compiled form */
len = xmlStrlen(value);
if (len > 0) {
- if ((value[len-1] == '-') ||
+ if ((value[len-1] == '-') ||
(xmlStrstr(value, BAD_CAST "--"))) {
xsltTransformError(ctxt, NULL, inst,
- "xsl:comment : '--' or ending '-' not allowed in comment\n");
+ "xsl:comment : '--' or ending '-' not allowed in comment\n");
/* fall through to try to catch further errors */
}
}
@@ -4155,7 +4141,7 @@ error:
* xsltCopyOf:
* @ctxt: an XSLT transformation context
* @node: the current node in the source tree
- * @inst: the element node of the XSLT copy-of instruction
+ * @inst: the element node of the XSLT copy-of instruction
* @castedComp: precomputed information of the XSLT copy-of instruction
*
* Process the XSLT copy-of instruction.
@@ -4218,7 +4204,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldXPContextSize = xpctxt->contextSize;
oldXPNsNr = xpctxt->nsNr;
oldXPNamespaces = xpctxt->namespaces;
-
+
xpctxt->node = node;
if (comp != NULL) {
@@ -4244,7 +4230,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
xpctxt->doc = oldXPContextDoc;
xpctxt->node = oldXPContextNode;
xpctxt->contextSize = oldXPContextSize;
- xpctxt->proximityPosition = oldXPProximityPosition;
+ xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->nsNr = oldXPNsNr;
xpctxt->namespaces = oldXPNamespaces;
@@ -4293,7 +4279,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
"xsltCopyOf: result is a result tree fragment\n"));
-#endif
+#endif
list = res->nodesetval;
if ((list != NULL) && (list->nodeTab != NULL) &&
(list->nodeTab[0] != NULL) &&
@@ -4321,7 +4307,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltCopyTextString(ctxt, ctxt->insert, value, 0);
}
xmlFree(value);
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_COPY_OF,xsltGenericDebug(xsltGenericDebugContext,
"xsltCopyOf: result %s\n", res->stringval));
@@ -4385,7 +4371,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
oldXPContextSize = xpctxt->contextSize;
oldXPNsNr = xpctxt->nsNr;
oldXPNamespaces = xpctxt->namespaces;
-
+
xpctxt->node = node;
if (comp != NULL) {
@@ -4411,7 +4397,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
xpctxt->doc = oldXPContextDoc;
xpctxt->node = oldXPContextNode;
xpctxt->contextSize = oldXPContextSize;
- xpctxt->proximityPosition = oldXPProximityPosition;
+ xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->nsNr = oldXPNsNr;
xpctxt->namespaces = oldXPNamespaces;
@@ -4432,14 +4418,14 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->insert, value, comp->noescape);
}
} else {
- xsltTransformError(ctxt, NULL, inst,
+ xsltTransformError(ctxt, NULL, inst,
"XPath evaluation returned no result.\n");
ctxt->state = XSLT_STATE_STOPPED;
- goto error;
+ goto error;
}
#ifdef WITH_XSLT_DEBUG_PROCESS
- if (value) {
+ if (value) {
XSLT_TRACE(ctxt,XSLT_TRACE_VALUE_OF,xsltGenericDebug(xsltGenericDebugContext,
"xsltValueOf: result '%s'\n", value));
}
@@ -4481,7 +4467,7 @@ xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
comp->numdata.doc = inst->doc;
comp->numdata.node = inst;
-
+
xsltNumberFormat(ctxt, &comp->numdata, node);
}
@@ -4639,7 +4625,7 @@ xsltCallTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
}
/*
- * Create a new frame using the params first
+ * Create a new frame using the params first
*/
xsltApplyXSLTTemplate(ctxt, node, comp->templ->content, comp->templ,
withParams);
@@ -4673,7 +4659,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltStylePreCompPtr comp = castedComp;
#endif
int i;
- xmlNodePtr cur, delNode = NULL, oldContextNode;
+ xmlNodePtr cur, delNode = NULL, oldContextNode;
xmlNodeSetPtr list = NULL, oldList;
xsltStackElemPtr withParams = NULL;
int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
@@ -4697,21 +4683,21 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
"xsltApplyTemplates: node: '%s'\n", node->name));
#endif
- xpctxt = ctxt->xpathCtxt;
+ xpctxt = ctxt->xpathCtxt;
/*
* Save context states.
*/
oldContextNode = ctxt->node;
oldMode = ctxt->mode;
- oldModeURI = ctxt->modeURI;
+ oldModeURI = ctxt->modeURI;
oldDocInfo = ctxt->document;
- oldList = ctxt->nodeList;
+ oldList = ctxt->nodeList;
/*
* The xpath context size and proximity position, as
* well as the xpath and context documents, may be changed
* so we save their initial state and will restore on exit
- */
+ */
oldXPContextSize = xpctxt->contextSize;
oldXPProximityPosition = xpctxt->proximityPosition;
oldXPDoc = xpctxt->doc;
@@ -4724,7 +4710,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
ctxt->mode = comp->mode;
ctxt->modeURI = comp->modeURI;
- if (comp->select != NULL) {
+ if (comp->select != NULL) {
xmlXPathObjectPtr res = NULL;
if (comp->comp == NULL) {
@@ -4760,7 +4746,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (res != NULL) {
if (res->type == XPATH_NODESET) {
list = res->nodesetval; /* consume the node set */
- res->nodesetval = NULL;
+ res->nodesetval = NULL;
} else {
xsltTransformError(ctxt, NULL, inst,
"The 'select' expression did not evaluate to a "
@@ -4773,13 +4759,13 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
/*
* Note: An xsl:apply-templates with a 'select' attribute,
* can change the current source doc.
- */
+ */
} else {
xsltTransformError(ctxt, NULL, inst,
"Failed to evaluate the 'select' expression.\n");
ctxt->state = XSLT_STATE_STOPPED;
goto error;
- }
+ }
if (list == NULL) {
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_APPLY_TEMPLATES,xsltGenericDebug(xsltGenericDebugContext,
@@ -4788,7 +4774,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
goto exit;
}
/*
- *
+ *
* NOTE: Previously a document info (xsltDocument) was
* created and attached to the Result Tree Fragment.
* But such a document info is created on demand in
@@ -4797,14 +4783,14 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
* In order to take care of potential keys we need to
* do some extra work for the case when a Result Tree Fragment
* is converted into a nodeset (e.g. exslt:node-set()) :
- * We attach a "pseudo-doc" (xsltDocument) to _private.
+ * We attach a "pseudo-doc" (xsltDocument) to _private.
* This xsltDocument, together with the keyset, will be freed
* when the Result Tree Fragment is freed.
- *
+ *
*/
#if 0
if ((ctxt->nbKeys > 0) &&
- (list->nodeNr != 0) &&
+ (list->nodeNr != 0) &&
(list->nodeTab[0]->doc != NULL) &&
XSLT_IS_RES_TREE_FRAG(list->nodeTab[0]->doc))
{
@@ -4907,7 +4893,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
* for xsltDoSortFunction().
*/
ctxt->nodeList = list;
- /*
+ /*
* Process xsl:with-param and xsl:sort instructions.
* (The code became so verbose just to avoid the
* xmlNodePtr sorts[XSLT_MAX_SORT] if there's no xsl:sort)
@@ -4929,7 +4915,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
if (cur->type == XML_TEXT_NODE) {
cur = cur->next;
continue;
- }
+ }
if (! IS_XSLT_ELEM(cur))
break;
if (IS_XSLT_NAME(cur, "with-param")) {
@@ -4943,24 +4929,24 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
xsltTemplatePtr oldCurTempRule =
ctxt->currentTemplateRule;
int nbsorts = 0;
- xmlNodePtr sorts[XSLT_MAX_SORT];
-
+ xmlNodePtr sorts[XSLT_MAX_SORT];
+
sorts[nbsorts++] = cur;
-
+
while (cur) {
-
+
#ifdef WITH_DEBUGGER
if (ctxt->debugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(cur, node, NULL, ctxt);
#endif
if (ctxt->state == XSLT_STATE_STOPPED)
break;
-
+
if (cur->type == XML_TEXT_NODE) {
cur = cur->next;
continue;
}
-
+
if (! IS_XSLT_ELEM(cur))
break;
if (IS_XSLT_NAME(cur, "with-param")) {
@@ -4969,7 +4955,7 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
param->next = withParams;
withParams = param;
}
- }
+ }
if (IS_XSLT_NAME(cur, "sort")) {
if (nbsorts >= XSLT_MAX_SORT) {
xsltTransformError(ctxt, NULL, cur,
@@ -4997,11 +4983,11 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
}
cur = cur->next;
}
- }
+ }
xpctxt->contextSize = list->nodeNr;
/*
* Apply templates for all selected source nodes.
- */
+ */
for (i = 0; i < list->nodeNr; i++) {
cur = list->nodeTab[i];
/*
@@ -5030,7 +5016,7 @@ error:
if (withParams != NULL)
xsltFreeStackElemList(withParams);
if (list != NULL)
- xmlXPathFreeNodeSet(list);
+ xmlXPathFreeNodeSet(list);
/*
* Restore context states.
*/
@@ -5065,8 +5051,8 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL))
return;
-
- /*
+
+ /*
* TODO: Content model checks should be done only at compilation
* time.
*/
@@ -5091,13 +5077,13 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
{
int testRes = 0, res = 0;
- xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
+ xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
xmlDocPtr oldXPContextDoc = xpctxt->doc;
int oldXPProximityPosition = xpctxt->proximityPosition;
int oldXPContextSize = xpctxt->contextSize;
xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
int oldXPNsNr = xpctxt->nsNr;
-
+
#ifdef XSLT_REFACTORED
xsltStyleItemWhenPtr wcomp = NULL;
#else
@@ -5107,9 +5093,9 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
/*
* Process xsl:when ---------------------------------------------------
*/
- while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {
+ while (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "when")) {
wcomp = cur->psvi;
-
+
if ((wcomp == NULL) || (wcomp->test == NULL) ||
(wcomp->comp == NULL))
{
@@ -5118,11 +5104,11 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
"The XSLT 'when' instruction was not compiled.\n");
goto error;
}
-
-
+
+
#ifdef WITH_DEBUGGER
if (xslDebugStatus != XSLT_DEBUG_NONE) {
- /*
+ /*
* TODO: Isn't comp->templ always NULL for xsl:choose?
*/
xslHandleDebugger(cur, contextNode, NULL, ctxt);
@@ -5137,7 +5123,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xpctxt->doc = oldXPContextDoc;
xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->contextSize = oldXPContextSize;
-
+
#ifdef XSLT_REFACTORED
if (wcomp->inScopeNs != NULL) {
xpctxt->namespaces = wcomp->inScopeNs->list;
@@ -5150,21 +5136,21 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xpctxt->namespaces = wcomp->nsList;
xpctxt->nsNr = wcomp->nsNr;
#endif
-
-
+
+
#ifdef XSLT_FAST_IF
res = xmlXPathCompiledEvalToBoolean(wcomp->comp, xpctxt);
-
+
if (res == -1) {
ctxt->state = XSLT_STATE_STOPPED;
goto error;
}
- testRes = (res == 1) ? 1 : 0;
-
+ testRes = (res == 1) ? 1 : 0;
+
#else /* XSLT_FAST_IF */
-
+
res = xmlXPathCompiledEval(wcomp->comp, xpctxt);
-
+
if (res != NULL) {
if (res->type != XPATH_BOOLEAN)
res = xmlXPathConvertBoolean(res);
@@ -5183,33 +5169,33 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
ctxt->state = XSLT_STATE_STOPPED;
goto error;
}
-
+
#endif /* else of XSLT_FAST_IF */
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
"xsltChoose: test evaluate to %d\n", testRes));
#endif
- if (testRes)
+ if (testRes)
goto test_is_true;
-
+
cur = cur->next;
}
-
+
/*
* Process xsl:otherwise ----------------------------------------------
*/
if (IS_XSLT_ELEM(cur) && IS_XSLT_NAME(cur, "otherwise")) {
-
+
#ifdef WITH_DEBUGGER
if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(cur, contextNode, NULL, ctxt);
#endif
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_CHOOSE,xsltGenericDebug(xsltGenericDebugContext,
"evaluating xsl:otherwise\n"));
-#endif
+#endif
goto test_is_true;
}
xpctxt->node = contextNode;
@@ -5232,7 +5218,7 @@ test_is_true:
}
process_sequence:
-
+
/*
* Instantiate the sequence constructor.
*/
@@ -5279,7 +5265,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
"xsltIf: test %s\n", comp->test));
#endif
-#ifdef XSLT_FAST_IF
+#ifdef XSLT_FAST_IF
{
xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
xmlDocPtr oldXPContextDoc = xpctxt->doc;
@@ -5288,11 +5274,11 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
int oldXPProximityPosition = xpctxt->proximityPosition;
int oldXPContextSize = xpctxt->contextSize;
int oldXPNsNr = xpctxt->nsNr;
- xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
-
+ xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
+
xpctxt->node = contextNode;
if (comp != NULL) {
-
+
#ifdef XSLT_REFACTORED
if (comp->inScopeNs != NULL) {
xpctxt->namespaces = comp->inScopeNs->list;
@@ -5311,7 +5297,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
}
/*
* This XPath function is optimized for boolean results.
- */
+ */
res = xmlXPathCompiledEvalToBoolean(comp->comp, xpctxt);
/*
@@ -5320,11 +5306,11 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
*/
if (oldLocalFragmentTop != ctxt->localRVT)
xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
-
+
xpctxt->doc = oldXPContextDoc;
xpctxt->node = oldXPContextNode;
xpctxt->contextSize = oldXPContextSize;
- xpctxt->proximityPosition = oldXPProximityPosition;
+ xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->nsNr = oldXPNsNr;
xpctxt->namespaces = oldXPNamespaces;
}
@@ -5333,7 +5319,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
XSLT_TRACE(ctxt,XSLT_TRACE_IF,xsltGenericDebug(xsltGenericDebugContext,
"xsltIf: test evaluate to %d\n", res));
#endif
-
+
if (res == -1) {
ctxt->state = XSLT_STATE_STOPPED;
goto error;
@@ -5345,7 +5331,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xsltApplySequenceConstructor(ctxt,
contextNode, inst->children, NULL);
}
-
+
#else /* XSLT_FAST_IF */
{
xmlXPathObjectPtr xpobj = NULL;
@@ -5359,11 +5345,11 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xmlNodePtr oldXPContextNode = xpctxt->node;
int oldXPProximityPosition = xpctxt->proximityPosition;
int oldXPContextSize = xpctxt->contextSize;
- int oldXPNsNr = xpctxt->nsNr;
-
+ int oldXPNsNr = xpctxt->nsNr;
+
xpctxt->node = contextNode;
if (comp != NULL) {
-
+
#ifdef XSLT_REFACTORED
if (comp->inScopeNs != NULL) {
xpctxt->namespaces = comp->inScopeNs->list;
@@ -5380,16 +5366,16 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xpctxt->namespaces = NULL;
xpctxt->nsNr = 0;
}
-
+
/*
* This XPath function is optimized for boolean results.
- */
+ */
xpobj = xmlXPathCompiledEval(comp->comp, xpctxt);
-
+
xpctxt->doc = oldXPContextDoc;
xpctxt->node = oldXPContextNode;
xpctxt->contextSize = oldXPContextSize;
- xpctxt->proximityPosition = oldXPProximityPosition;
+ xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->nsNr = oldXPNsNr;
xpctxt->namespaces = oldXPNamespaces;
}
@@ -5398,7 +5384,7 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xpobj = xmlXPathConvertBoolean(xpobj);
if (xpobj->type == XPATH_BOOLEAN) {
res = xpobj->boolval;
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_IF,xsltGenericDebug(xsltGenericDebugContext,
"xsltIf: test evaluate to %d\n", res));
@@ -5430,7 +5416,7 @@ error:
/**
* xsltForEach:
* @ctxt: an XSLT transformation context
- * @contextNode: the "current node" in the source tree
+ * @contextNode: the "current node" in the source tree
* @inst: the element node of the xsl:for-each instruction
* @castedComp: the compiled information of the instruction
*
@@ -5449,16 +5435,16 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xmlXPathObjectPtr res = NULL;
xmlNodePtr cur, curInst;
xmlNodeSetPtr list = NULL;
- xmlNodeSetPtr oldList;
+ xmlNodeSetPtr oldList;
int oldXPProximityPosition, oldXPContextSize;
xmlNodePtr oldContextNode;
- xsltTemplatePtr oldCurTemplRule;
+ xsltTemplatePtr oldCurTemplRule;
xmlDocPtr oldXPDoc;
xsltDocumentPtr oldDocInfo;
xmlXPathContextPtr xpctxt;
if ((ctxt == NULL) || (contextNode == NULL) || (inst == NULL)) {
- xsltGenericError(xsltGenericErrorContext,
+ xsltGenericError(xsltGenericErrorContext,
"xsltForEach(): Bad arguments.\n");
return;
}
@@ -5476,7 +5462,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
"instruction was not compiled correctly.\n");
return;
}
- xpctxt = ctxt->xpathCtxt;
+ xpctxt = ctxt->xpathCtxt;
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
@@ -5487,7 +5473,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
* Save context states.
*/
oldDocInfo = ctxt->document;
- oldList = ctxt->nodeList;
+ oldList = ctxt->nodeList;
oldContextNode = ctxt->node;
/*
* The "current template rule" is cleared for the instantiation of
@@ -5514,8 +5500,8 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
#else
xpctxt->namespaces = comp->nsList;
xpctxt->nsNr = comp->nsNr;
-#endif
-
+#endif
+
/*
* Evaluate the 'select' expression.
*/
@@ -5527,7 +5513,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
else {
xsltTransformError(ctxt, NULL, inst,
"The 'select' expression does not evaluate to a node set.\n");
-
+
#ifdef WITH_XSLT_DEBUG_PROCESS
XSLT_TRACE(ctxt,XSLT_TRACE_FOR_EACH,xsltGenericDebug(xsltGenericDebugContext,
"xsltForEach: select didn't evaluate to a node list\n"));
@@ -5555,12 +5541,12 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
xpctxt->contextSize = oldXPContextSize;
xpctxt->proximityPosition = oldXPProximityPosition;
xpctxt->node = contextNode;
-
+
/*
* Set the list; this has to be done already here for xsltDoSortFunction().
*/
- ctxt->nodeList = list;
- /*
+ ctxt->nodeList = list;
+ /*
* Handle xsl:sort instructions and skip them for further processing.
* BUG TODO: We are not using namespaced potentially defined on the
* xsl:sort element; XPath expression might fail.
@@ -5588,7 +5574,7 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
} else {
sorts[nbsorts++] = curInst;
}
-
+
#ifdef WITH_DEBUGGER
if (xslDebugStatus != XSLT_DEBUG_NONE)
xslHandleDebugger(curInst, contextNode, NULL, ctxt);
@@ -5596,11 +5582,11 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
curInst = curInst->next;
}
xsltDoSortFunction(ctxt, sorts, nbsorts);
- }
+ }
xpctxt->contextSize = list->nodeNr;
/*
* Instantiate the sequence constructor for each selected node.
- */
+ */
for (i = 0; i < list->nodeNr; i++) {
cur = list->nodeTab[i];
/*
@@ -5727,7 +5713,7 @@ xsltApplyStripSpaces(xsltTransformContextPtr ctxt, xmlNodePtr node) {
while (cur != NULL) {
if (IS_BLANK_NODE(cur))
delete = cur;
-
+
cur = cur->next;
if (delete != NULL) {
xmlUnlinkNode(delete);
@@ -5924,7 +5910,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
} else {
if (version == NULL) {
xmlDtdPtr dtd;
-
+
res = htmlNewDoc(NULL, NULL);
/*
* Make sure no DTD node is generated in this case
@@ -6010,14 +5996,14 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
* and start by processing the top node.
*/
if (xsltNeedElemSpaceHandling(ctxt))
- xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));
+ xsltApplyStripSpaces(ctxt, xmlDocGetRootElement(doc));
/*
* Evaluate global params and user-provided params.
*/
ctxt->node = (xmlNodePtr) doc;
if (ctxt->globalVars == NULL)
ctxt->globalVars = xmlHashCreate(20);
- if (params != NULL) {
+ if (params != NULL) {
xsltEvalUserParams(ctxt, params);
}