您可以在此处使用名为 concat 的命名相当合理的 xpath 函数
<a>
<xsl:attribute name="href">
<xsl:value-of select="concat('myText:', /*/properties/property[@name='report']/@value)" />
</xsl:attribute>
</a>
当然,这里不一定非得是文本,可以是另一个xpath表达式来选择一个元素或属性。您可以在 concat 表达式中包含任意数量的参数。
请注意,您可以在此处使用属性值模板(由大括号表示)来简化您的表达式
<a href="{concat('myText:', /*/properties/property[@name='report']/@value)}"></a>
三个答案:
简单的 :
<img>
<xsl:attribute name="src">
<xsl:value-of select="//your/xquery/path"/>
<xsl:value-of select="'vmLogo.gif'"/>
</xsl:attribute>
</img>
使用“连接”:
<img>
<xsl:attribute name="src">
<xsl:value-of select="concat(//your/xquery/path,'vmLogo.gif')"/>
</xsl:attribute>
</img>
@TimC 建议的属性快捷方式
<img src="{concat(//your/xquery/path,'vmLogo.gif')}" />
<img src="{//your/xpath}vmLogo.gif" />
利用:
<a href="wantedText{/*/properties/property[@name='report']/@value)}"></a>
将静态文本字符串连接到选定值的最简单方法是使用 element.
<a>
<xsl:attribute name="href">
<xsl:value-of select="/*/properties/property[@name='report']/@value" />
<xsl:text>staticIconExample.png</xsl:text>
</xsl:attribute>
</a>
最简单的方法是
<TD>
<xsl:value-of select="concat(//author/first-name,' ',//author/last-name)"/>
</TD>
当 XML 结构为
<title>The Confidence Man</title>
<author>
<first-name>Herman</first-name>
<last-name>Melville</last-name>
</author>
<price>11.99</price>
不是最易读的解决方案,但您可以将 value-of 的结果与纯文本混合:
<a>
<xsl:attribute name="href">
Text<xsl:value-of select="/*/properties/property[@name='report']/@value"/>Text
</xsl:attribute>
</a>
' Text'
),将输出空白(甚至是新行)。
concat()
函数。<a title="" href="/page.cfm?id=425">Anders, John</a>
,我想在 XSLT 中创建一个隐藏字段,它只接受 ID #。我怎样才能做到这一点?