Rank: Newbie
Joined: 6/5/2019 Posts: 1
|
I am getting a 'Parameter or variable with this name already defined name="nested-refs"' error on the following code even though the variable is local to the individual templates. I can run this code with no problem in our Linus XSL processor. Is it the case that there is a param with the same name?
Code:<xsl:template match="item.reference"> <xsl:value-of select="$newline"/> <xsl:variable name="ref-kids" select="*[local-name() != 'name.block' and local-name() != 'item.reference']"/> <xsl:variable name="nested-refs" select="*[local-name() = 'item.reference']"/> <xsl:element name="ref"> <xsl:element name="n"> <xsl:call-template name="get_name_label_designator"/> </xsl:element> <xsl:apply-templates select="$ref-kids"/> </xsl:element> <xsl:call-template name="process-item-references"> <xsl:with-param name="nested-refs" select="$nested-refs"/> </xsl:call-template> </xsl:template> <xsl:template name="process-item-references"> <xsl:param name="nested-refs"/> <xsl:for-each select="$nested-refs"> <xsl:variable name="ref-kids" select="*[local-name() != 'name.block' and local-name() != 'item.reference']"/> <xsl:variable name="nested-refs" select="*[local-name() = 'item.reference']"/> <xsl:element name="ref"> <xsl:element name="n"> <xsl:call-template name="get_name_label_designator"/> </xsl:element> <xsl:apply-templates select="$ref-kids"/> </xsl:element> <xsl:call-template name="process-item-references"> <xsl:with-param name="nested-refs" select="$nested-refs"/> </xsl:call-template> </xsl:for-each> </xsl:template> Thanks Chris
|
Rank: Advanced Member
Joined: 2/27/2009 Posts: 558
|
Your XSLT is invalid XSLT 1.0, but could be valid XSLT 2.0. At least, the error you mention isn't shown when you treat it as XSLT 2.0.
XSLT 1.0, you couldn't define a local variable in the same scope as another local variable or param with the same name. Apparently some XSLT 1.0 processors did not enforce this. In XSLT 2.0 it's allowed though still not recommended.
|