将字符串连接到 xslt 中的变量时出错

Error while concatenating a string to variable in xslt

请帮助我处理这段代码,它在第 3 行给出了 "too many items" 的错误:

<xsl:when test=".[@name='Measurement Pallete']">
    <xsl:variable name="controlID" select=".[@name='Measurement Pallete']/Control/@id"/>
    <xsl:variable name="control_ID" select="translate($controlID, ' ', '')"/>
    <xsl:variable name="funcName" select="concat('ClassicTab', $control_ID)"/>              
</xsl:when>

输入Xml的格式为

<window name="">
    <Control id="" type=""/>
    <Control id="" type=""/>
</window>

我希望变量 funcname 应该在每个控件的名称之前连接 "HomeTab",其中 window 名称是 "Measurement Pallete"

完成样式表

<xsl:template match="/">
        <xsl:for-each select="//window">
            <xsl:result-document href="{concat('Windows/', @id,  '.cs')}">
                <xsl:choose>
                    <xsl:when test="current()[@name='Measurement Pallete']">
                        <xsl:variable name="controlID" select="current()[@name='Measurement Pallete']/Control/@id"/>
                        <xsl:variable name="control_ID" select="translate($controlID, ' ', '')"/>
                        <xsl:variable name="funcName" select="concat('ClassicTab', $control_ID)"/>
                        <xsl:call-template name="csfile1">
                            <xsl:with-param name="func_name" select="$funcName"/>
                        </xsl:call-template>
                        <xsl:call-template name="automationIDs1">
                            <xsl:with-param name="func_name" select="$funcName"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="csfile"/>
                        <xsl:call-template name="automationIDs"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:result-document>
        </xsl:for-each>
    </xsl:template>

这是因为 $controlID 输出了 2 个值(我假设这是 xsl 2.0 因为 xsl:result-document),Control[1]/@idControl[2]/@id,错误来自

<xsl:variable name="control_ID" select="translate($controlID, ' ', '')"/>

因为您不能将多个序列作为 translate 的第一个参数。