How do I parse the URL in the results link to get the filename for output?

Just add the following code to the XSL file and call it to output the filename.

Code:
@@@
<xsl:template name="filename">
<xsl:param name="x"/>
<xsl:choose>
<!-- Set the correct file separator -->
<xsl:when test="contains($x,'\')">
<xsl:call-template name="filename">
<!-- Set the correct file separator -->
<xsl:with-param name="x" select="substring-after($x,'\')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$x"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@@

Depending on the OS you are using to indexing your documents, use the correct file separator in this template. Note that you have to set the file separator in two places.

Th above template should be called as follows:-

Code:
@@@
<xsl:call-template name="filename">
<xsl:with-param name="x" select="url" />
</xsl:call-template>
@@@

Have more questions? Submit a request

Comments