[xslt] RE: xsl:variable scope problem with 0.10 ?
- From: "Vakoc, Mark" <Mark_Vakoc jdedwards com>
- To: "'xslt xmlsoft org'" <xslt xmlsoft org>
- Subject: [xslt] RE: xsl:variable scope problem with 0.10 ?
- Date: Tue, 22 May 2001 15:26:51 -0600
Of course, as soon as I wrote that I think I found it. Below is the
original code from function xsltStackLookup in variables.c (sorry, I don't
have diff capability)
If ctxt->varsNr is 1, the for loop below will not be processed, and the
variable won't be found. Changing the for loop to
for(;i>=0;i++) will work. So I believe that as it is, it will always fail
to find the first defined variable in the context stack.
/*
* Do the lookup from the top of the stack, but
* don't use params being computed in a call-param
*/
i = ctxt->varsNr - 1;
for (;i > 0;i--) {
cur = ctxt->varsTab[i];
while (cur != NULL) {
if (xmlStrEqual(cur->name, name)) {
if (nameURI == NULL) {
if (cur->nameURI == NULL) {
return(cur);
}
} else {
if ((cur->nameURI != NULL) &&
(xmlStrEqual(cur->nameURI, nameURI))) {
return(cur);
}
}
}
cur = cur->next;
}
> -----Original Message-----
>
> Applying the first stylesheet below against any document will fail with
> the following output from xsltProc.
>
> unregistered variable var
> unregistered variable var
> xmlXPathEval: evaluation failed
> xsltDefaultProcessOneNode: text copy failed
>
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:template match="/">
> <xsl:variable name="var" select="string('mark')"/>
> <xsl:value-of select="$var"/>
> </xsl:template>
> </xsl:stylesheet>
>
> The following works without problems.
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:variable name="var" select="string('mark')"/>
> <xsl:template match="/">
> <xsl:value-of select="$var"/>
> </xsl:template>
> </xsl:stylesheet>
>
> This seems to be a problem with 0.10 but worked with prior releases. I
> have tried to trace through the code to isolate the problem, but am
> struggling with the learning curve of the libxslt internals.
>
> Does anyone have any ideas?
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]