1

「imageText」を非表示にしたいのですが、div IF 文字列が空です。現時点では、この imageText はテキストを背景色付きの画像にオーバーレイします (テキストは Umbraco で指定されています)。

私はすでに試しました:

<xsl:if test = "imageText" != ''">

誰かがこれを達成するのを手伝ってくれませんか?

これが私のコードです:

<td width="300" height="114" valign="top">

    <div class="imageTitle">
    <xsl:call-template name="getText">
      <xsl:with-param name="imageText" select="$bottomImageLeftText" />
    </xsl:call-template>   
    </div>

    </td>
4

3 に答える 3

1

と呼ばれる要素内のテキストですかimageText、それとも と呼ばれる変数内にあります$bottomImageLeftTextか? 後者のようですので、これを試してみてください:

<td width="300" height="114" valign="top">
  <xsl:if test="$bottomImageLeftText != ''">
    <div class="imageTitle">
      <xsl:call-template name="getText">
        <xsl:with-param name="imageText" select="$bottomImageLeftText" />
      </xsl:call-template>   
    </div>
  </xsl:if>
</td>
于 2013-03-11T10:42:10.663 に答える
0

パラメータ名ではなく、に渡す値を条件とする必要があります (これは、呼び出されたテンプレートwith-paramでのみ意味があります)。したがって、要素をdiv

<xsl:if test="string($bottomImageLeftText)">

$bottomImageLeftTextの文字列値が空でない場合、これには div とその内容が含まれます。これには、空白のみが含まれる場合が含まれます。空白のみを完全に空と同じように扱いたい場合は、使用できます

<xsl:if test="normalize-space($bottomImageLeftText)">
于 2013-03-11T10:46:05.807 に答える
0

私はこのようなことを試してみます:

<!-- Code which calls the getText template and passes the bottomImageLeftText variable -->
<xsl:call-template name="getText">
  <xsl:with-param name="imageText" select="$bottomImageLeftText" />
</xsl:call-template>

<!-- getText template which checks the param imageText for an empty string. -->
  <xsl:template name="getText" >
    <xsl:param name="imageText" />

    <xsl:if test="$imageText" >
      <div class="imageTitle">
        <!-- your code, display image title -->
      </div>
      </xsl:if>
  </xsl:template>
于 2013-03-11T10:48:04.650 に答える