100
<a>
    <xsl:attribute name="href"> 
     <xsl:value-of select="/*/properties/property[@name='report']/@value" />
    </xsl:attribute>
</a>    

別の文字列を連結する方法はありますか

<xsl:value-of select="/*/properties/property[@name='report']/@value"  />

レポートのプロパティ値に加えて、href 属性にテキストを渡す必要があります。

4

6 に答える 6

160

ここでは、 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>
于 2012-05-01T09:45:31.860 に答える
28

3つの答え:

単純 :

<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')}" />
于 2013-05-20T09:37:20.237 に答える
16

使用:

<a href="wantedText{/*/properties/property[@name='report']/@value)}"></a>
于 2012-05-01T12:28:08.213 に答える
5

静的テキスト文字列を選択した値に連結する最も簡単な方法は、エレメント。

<a>
  <xsl:attribute name="href"> 
    <xsl:value-of select="/*/properties/property[@name='report']/@value" />
    <xsl:text>staticIconExample.png</xsl:text>
  </xsl:attribute>
</a>
于 2013-07-11T07:51:11.887 に答える