1
我有例如字符串:XSLT - 之前獲取字符串最後一個「/」
<path> c:/users/xyz/test_files/test.xml </path>
,我想之前得到的字符串最後「/」那就是:
C:/用戶/ xyz/test_files
在此先感謝。
我有例如字符串:XSLT - 之前獲取字符串最後一個「/」
<path> c:/users/xyz/test_files/test.xml </path>
,我想之前得到的字符串最後「/」那就是:
C:/用戶/ xyz/test_files
在此先感謝。
嘗試這樣:
<xsl:variable name="tokens" select="tokenize(.,'/')"/>
<xsl:value-of select="$tokens[not(.=$tokens[last()])]" separator="/"/>
這是假設當前上下文path
。
<xsl:template match="path">
<xsl:variable name="p" select="string-join(tokenize(., '/')[position() lt last()], '/')"/>
</xsl:template>
應該做的。