小编dhi*_*inu的帖子

我们可以在xslt的select语句中使用动态变量名吗?

我想在xslt的select语句中使用动态变量名.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
    <xsl:variable name="input" select="input/message" />
    <xsl:variable name="Name" select="'MyName'" />
    <xsl:variable name="Address" select="MyAddress" />
    <xsl:variable name="output" select="concat('$','$input')" />  <!-- This is not working -->
     <output>
       <xsl:value-of select="$output" />
     </output>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)

变量"input"的可能值为"Name"或"Address".输出变量的select语句应该具有基于输入变量值的动态变量名.我不想使用xsl:choose.我想动态选择值.请给我一个解决方案.

谢谢,dhinu

xslt xslt-1.0

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

xslt ×1

xslt-1.0 ×1