2010-07-30 70 views

回答

8

或者你可以做等同於,如果在XSL/else語句:

<xsl:choose> 
    <xsl:when test="string-length($Title) = 12"> 
    <!-- code when the check is true --> 
    </xsl:when> 
    <xsl:otherwise> 
    <!-- code when it's false --> 
    </xsl:otherwise> 
</xsl:choose> 
+0

非常感謝您的幫助MAQ – NWhite 2010-08-02 08:11:00

+0

我也似乎注意到,這並不計數空間''..有沒有一種方法可以讓這些計數以及? – NWhite 2010-08-02 12:30:38

0

string-length($varname)會告訴你一個包含數據的變量的長度,該數據可以被解釋爲一個字符串。

+0

非常感謝您的幫助 – NWhite 2010-07-30 16:06:08

1

在XPath 1.0:

string-length($title) = 12 

採取通知該區別標記也將被計數。

在XPath 2.0你cuold使用:

string-length(normalize-unicode($title)) = 12 
1

基本上我需要找到 角色多少都在一個變量使用XSL

if characters($Title == 12) { execute code; } 

使用

<xsl:if test="string-length($Title) = 12"> 
    <!-- Your code here --> 
</xsl:if> 
相關問題