Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 删除XSLT中路径的第一个元素_String_Xslt_Tokenize - Fatal编程技术网

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

String 删除XSLT中路径的第一个元素,string,xslt,tokenize,String,Xslt,Tokenize,我试图删除XSLT2.0中路径字符串的前3个“标记” 例如,从D:/FolderA/folderB/folderC/file.ext转到folderC/file.ext 除了使用我正在努力编写的递归函数,我找不到一个快速的方法来实现它 <xsl:variable name="tokenizedPath" select="(tokenize($url,'/'))" /> <xsl:value-of select="yy:restofpath($tokenizedPath,2)"

我试图删除XSLT2.0中路径字符串的前3个“标记”

例如,从
D:/FolderA/folderB/folderC/file.ext
转到
folderC/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], '/')"/>

很棒,简单的Xpath,很棒!谢谢!