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->tree = tree;
|
||||
tmp = style->variables;
|
||||
if (tmp == NULL) {
|
||||
elem->next = NULL;
|
||||
style->variables = elem;
|
||||
} else {
|
||||
while (tmp != NULL) {
|
||||
if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||
(tmp->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||
(xmlStrEqual(elem->name, tmp->name)) &&
|
||||
((elem->nameURI == tmp->nameURI) ||
|
||||
(xmlStrEqual(elem->nameURI, tmp->nameURI))))
|
||||
{
|
||||
xsltTransformError(NULL, style, comp->inst,
|
||||
"redefinition of global variable %s\n", elem->name);
|
||||
style->errors++;
|
||||
}
|
||||
if (tmp->next == NULL)
|
||||
break;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
elem->next = NULL;
|
||||
tmp->next = elem;
|
||||
while (tmp != NULL) {
|
||||
if ((elem->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||
(tmp->comp->type == XSLT_FUNC_VARIABLE) &&
|
||||
(xmlStrEqual(elem->name, tmp->name)) &&
|
||||
((elem->nameURI == tmp->nameURI) ||
|
||||
(xmlStrEqual(elem->nameURI, tmp->nameURI))))
|
||||
{
|
||||
xsltTransformError(NULL, style, comp->inst,
|
||||
"redefinition of global variable %s\n", elem->name);
|
||||
style->errors++;
|
||||
}
|
||||
tmp = tmp->next;
|
||||
}
|
||||
elem->next = style->variables;;
|
||||
style->variables = elem;
|
||||
if (value != NULL) {
|
||||
elem->computed = 1;
|
||||
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