2011-05-19 179 views
-1

我有一個包含字符串值的變量serviceProvideList如何避免從字符串變量中獲取重複的字符串?

我用下面的代碼分別獲得每個字符串:

<xsl:variable name="tokenizedSample" select="str:tokenize($serviceProvideList,'&#xa;')"/> 

<xsl:for-each select="$tokenizedSample"> 
    <xsl:variable name="weakProvide" select="."/> 
    <xsl:variable name="tokenized" select="str:tokenize($weakProvide,' ')"/> 

    <xsl:for-each select="$tokenized"> 
    <xsl:variable name="weakP" select="."/> 
    <xsl:value-of select="$weakP"/> 
    </xsl:for-each> 
</xsl:for-each> 

如何避免在變量serviceProvideList重複值?

+1

看來是http://stackoverflow.com/questions/6054688/how-to-check-repeated的複本-elements功能於作爲串序列陣列。請不要多次提問同一個問題。 – 2011-05-19 15:59:13

回答

1

排除標記,其具有相同的值precedings,從for-each循環:

<xsl:for-each select="$tokenizedSample[ not(preceding-sibling::* = .) ]"> 
+1

當for-each序列中的項不是節點時,你確定前同胞是否可以工作? – LarsH 2011-05-19 17:14:10

+1

exslt函數'str:tokenize'結果是節點集。 [doc](http://exslt.org/str/functions/tokenize/index.html) – 2011-05-20 06:29:24

+0

啊...我假設它與XPath 2.0'tokenize()'函數相同。 – LarsH 2011-05-20 16:18:41

相關問題