mirror of
https://gitlab.gnome.org/GNOME/libxslt
synced 2025-07-31 02:43:06 +03:00
variables: Evaluate globals in source order
This commit is contained in:
@ -1403,28 +1403,21 @@ xsltRegisterGlobalVariable(xsltStylesheetPtr style, const xmlChar *name,
|
|||||||
elem->nameURI = xmlDictLookup(style->dict, ns_uri, -1);
|
elem->nameURI = xmlDictLookup(style->dict, ns_uri, -1);
|
||||||
elem->tree = tree;
|
elem->tree = tree;
|
||||||
tmp = style->variables;
|
tmp = style->variables;
|
||||||
if (tmp == NULL) {
|
while (tmp != NULL) {
|
||||||
elem->next = NULL;
|
if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||||
style->variables = elem;
|
(tmp->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||||
} else {
|
(xmlStrEqual(elem->name, tmp->name)) &&
|
||||||
while (tmp != NULL) {
|
((elem->nameURI == tmp->nameURI) ||
|
||||||
if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
|
(xmlStrEqual(elem->nameURI, tmp->nameURI))))
|
||||||
(tmp->comp->type == XSLT_FUNC_VARIABLE) &&
|
{
|
||||||
(xmlStrEqual(elem->name, tmp->name)) &&
|
xsltTransformError(NULL, style, comp->inst,
|
||||||
((elem->nameURI == tmp->nameURI) ||
|
"redefinition of global variable %s\n", elem->name);
|
||||||
(xmlStrEqual(elem->nameURI, tmp->nameURI))))
|
style->errors++;
|
||||||
{
|
}
|
||||||
xsltTransformError(NULL, style, comp->inst,
|
tmp = tmp->next;
|
||||||
"redefinition of global variable %s\n", elem->name);
|
|
||||||
style->errors++;
|
|
||||||
}
|
|
||||||
if (tmp->next == NULL)
|
|
||||||
break;
|
|
||||||
tmp = tmp->next;
|
|
||||||
}
|
|
||||||
elem->next = NULL;
|
|
||||||
tmp->next = elem;
|
|
||||||
}
|
}
|
||||||
|
elem->next = style->variables;;
|
||||||
|
style->variables = elem;
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
elem->computed = 1;
|
elem->computed = 1;
|
||||||
elem->value = xmlXPathNewString(value);
|
elem->value = xmlXPathNewString(value);
|
||||||
|
9
tests/general/bug-224.out
Normal file
9
tests/general/bug-224.out
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<result>
|
||||||
|
id1
|
||||||
|
id2
|
||||||
|
id3
|
||||||
|
id4
|
||||||
|
id5
|
||||||
|
id6
|
||||||
|
</result>
|
8
tests/general/bug-224.xml
Normal file
8
tests/general/bug-224.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<doc>
|
||||||
|
<item/>
|
||||||
|
<item/>
|
||||||
|
<item/>
|
||||||
|
<item/>
|
||||||
|
<item/>
|
||||||
|
<item/>
|
||||||
|
</doc>
|
28
tests/general/bug-224.xsl
Normal file
28
tests/general/bug-224.xsl
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:variable name="v1" select="generate-id(doc/item[1])"/>
|
||||||
|
<xsl:variable name="v2" select="generate-id(doc/item[2])"/>
|
||||||
|
<xsl:variable name="v3" select="generate-id(doc/item[3])"/>
|
||||||
|
<xsl:variable name="v4" select="generate-id(doc/item[4])"/>
|
||||||
|
<xsl:variable name="v5" select="generate-id(doc/item[5])"/>
|
||||||
|
<xsl:variable name="v6" select="generate-id(doc/item[6])"/>
|
||||||
|
|
||||||
|
<xsl:template match="/">
|
||||||
|
<result>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v1"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v2"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v3"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v4"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v5"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
<xsl:value-of select="$v6"/>
|
||||||
|
<xsl:text>
</xsl:text>
|
||||||
|
</result>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
Reference in New Issue
Block a user