+Thu Oct 17 16:32:44 CEST 2002 Daniel Veillard <daniel@veillard.com>
+
+ * libxslt/variables.c: fixed bug #86421
+ * tests/docs/Makefile.am tests/docs/bug-94.xml
+ tests/general/Makefile.am tests/general/bug-94.*: added the
+ example in the regression tests for this case
+
Thu Oct 17 15:50:04 CEST 2002 Daniel Veillard <daniel@veillard.com>
* xsltproc: added and tested the --path option to close #79638
*
* check wether the variable or param is already defined
*
- * Returns 1 if present, 0 if not, -1 in case of failure.
+ * Returns 1 if variable is present, 2 if param is present, 3 if this
+ * is an inherited param, 0 if not found, -1 in case of failure.
*/
static int
xsltCheckStackElem(xsltTransformContextPtr ctxt, const xmlChar *name,
if (((nameURI == NULL) && (cur->nameURI == NULL)) ||
((nameURI != NULL) && (cur->nameURI != NULL) &&
(xmlStrEqual(nameURI, cur->nameURI)))) {
+ if ((cur->comp != NULL) &&
+ (cur->comp->type == XSLT_FUNC_WITHPARAM))
+ return(3);
+ if ((cur->comp != NULL) &&
+ (cur->comp->type == XSLT_FUNC_PARAM))
+ return(2);
return(1);
}
}
xsltRegisterVariable(xsltTransformContextPtr ctxt, xsltStylePreCompPtr comp,
xmlNodePtr tree, int param) {
xsltStackElemPtr elem;
+ int present;
- if (xsltCheckStackElem(ctxt, comp->name, comp->ns) != 0) {
- if (!param) {
+ present = xsltCheckStackElem(ctxt, comp->name, comp->ns);
+ if (param == 0) {
+ if ((present != 0) && (present != 3)) {
xsltTransformError(ctxt, NULL, comp->inst,
- "xsl:variable : redefining %s\n", comp->name);
+ "xsl:variable : redefining %s\n", comp->name);
+ return(0);
+ }
+ } else if (present != 0) {
+ if ((present == 1) || (present == 2)) {
+ xsltTransformError(ctxt, NULL, comp->inst,
+ "xsl:param : redefining %s\n", comp->name);
+ return(0);
}
#ifdef WITH_XSLT_DEBUG_VARIABLE
- else
- xsltGenericDebug(xsltGenericDebugContext,
- "param %s defined by caller\n", comp->name);
+ xsltGenericDebug(xsltGenericDebugContext,
+ "param %s defined by caller\n", comp->name);
#endif
return(0);
}
--- /dev/null
+<xsl:stylesheet version = '1.0'
+ xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
+<!-- borrowed from http://www.zvon.org/xxl/XSLTutorial/Output/example35_ch9.html -->
+
+<xsl:template match="/">
+ <TABLE>
+ <xsl:for-each select="//number">
+ <TR>
+ <TH>
+ <xsl:choose>
+ <xsl:when test="text() mod 2">
+ <xsl:apply-templates select=".">
+ <xsl:with-param name="type">odd</xsl:with-param>
+ </xsl:apply-templates>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </TH>
+ </TR>
+ </xsl:for-each>
+ </TABLE>
+</xsl:template>
+
+<xsl:template match="number">
+ <xsl:variable name="type">even</xsl:variable>
+ <xsl:value-of select="."/>
+ <xsl:text> (</xsl:text>
+ <xsl:value-of select="$type"/>
+ <xsl:text>)</xsl:text>
+</xsl:template>
+
+
+</xsl:stylesheet>