仅使用XSLT 1.0的字符串函数,我将如何切断网址的末尾?
所以来自
http://stackoverflow.com/questions/2981175/is-it-possible-to-slice-the-end-of-a-url-with-xslt-1-0
我想提取
是-IT-可能对切片的-结束-A-URL与 - XSLT-1-0
这可能吗?
不幸的是,XSLT/XPath 1.0中没有substring-after-last函数.因此,要获取URL的最后一部分,您必须编写递归模板,如Jeni Tenisson所述:
<xsl:template name="substring-after-last">
<xsl:param name="string" />
<xsl:param name="delimiter" />
<xsl:choose>
<xsl:when test="contains($string, $delimiter)">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="string"
select="substring-after($string, $delimiter)" />
<xsl:with-param name="delimiter" select="$delimiter" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$string" /></xsl:otherwise>
</xsl:choose>
</xsl:template>
Run Code Online (Sandbox Code Playgroud)
这个模板将被调用,例如:
<xsl:call-template name="substring-after-last">
<xsl:with-param name="string" select="$url" />
<xsl:with-param name="delimiter" select="'/'" />
</xsl:call-template>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1327 次 |
| 最近记录: |