0
我有一个HTML文件,我想用XSLT 1.0 文件的格式为<file name="/var/application-data/..../application/controllers/cgu.php" />
XSL解析文件名文件夹
解析,我想这是 <file filename="cgu.php" folderName="controller/"/>
我管理这个使用<xsl:value-of select="substring-before(substring(@name, 85), '/')"/>
做 ,但我希望它适用于所有长度的路径。 是否可以计算“/”的出现次数来检索路径的最后部分?
我用递归模板只检索文件名,但我需要的文件夹名称也
<xsl:template name="substring-after-last">
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="contains($string, '/')">
<xsl:call-template name="substring-after-last">
<xsl:with-param name="string" select="substring-after($string, '/')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
参见:http://stackoverflow.com/questions/38848374/how-to-find-最后的预览工作和存储到我的领域在xslt/38848925#38848925和http://stackoverflow.com/questions/41624974/xsl-display-attribute-after-a-certain-字符/ 41625340#41625340 –