删除 XSLT 中路径的第一个元素

Remove the first elements of a path in XSLT

我正在尝试删除 XSLT 2.0 中路径查找字符串的前 3 个 'tokens'。

例如,从 D:/FolderA/folderB/folderC/file.extfolderC/file.ext

除了使用我正在努力编写的递归函数之外,我找不到快速的想法。

<xsl:variable name="tokenizedPath" select="(tokenize($url,'/'))" />
<xsl:value-of select="yy:restofpath($tokenizedPath,2)" />

其中 yy:restofpath 可能类似于:

<xsl:function name="yy:restofpath" as="xs:string">
  <xsl:param name="pathtokens"/>
  <xsl:param name="startIndex"/>
  <xsl:variable name="length" select="count($pathtokens)"/>
  <xsl:for-each select="$pathtokens">
    <xsl:value-of select="string-join(.,yy:restofpath($pathtokens,),'')"/>
  </xsl:for-each>
</xsl:function>

这是一个我不会写的笨函数,我很困惑如何处理我的标记化字符串。

也许有更简单的内置方法来做到这一点?

鉴于:

<xsl:variable name="tokenizedPath" select="tokenize($url,'/')" />

那么你可以使用:

<xsl:value-of select="string-join($tokenizedPath[position() gt 3], '/')"/>