2

I have a requirement where I need to get the location of a document(Library Name/Folder Name/SubFolder Name) inside a document library using XSLT. Can anyone help me?

For example i have

http://Mysite:2016/dms/xxxx-DMS-yyyy/Lists/LibraryName/FolderName/SubFolderName/FileName.docx 

and my requirement is to get

http://Mysite:2016/dms/xxxx-DMS-yyyy/Lists/LibraryName/FolderName/SubFolderName/
2

<xsl:value-of "@FileLeafRef /> should get you most if not all of what you want.

Some of it will have to be built manually or by using server variables, http://sympmarc.com/2007/10/19/data-view-web-part-parameters-based-on-server-variables/.

In that case, you would just use a concat to string them all together, <xsl:value-of "concat($SomeVariable,"/",@FileLeafRef />, but you shouldn't need to do a full URL, a relative url to the document should suffice.

0

Atlast I found the solution.

<a id="{concat($currentId,'_Title')}"> <xsl:attribute name="href"> <xsl:call-template name="substring-before-last"> <xsl:with-param name="list" select="url"/> <xsl:with-param name="delimiter" select="'/'"/> </xsl:call-template> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:attribute name="title"> <xsl:value-of select="title"/> </xsl:attribute> <xsl:choose> <xsl:when test="hithighlightedproperties/HHTitle[. != '']"> <xsl:call-template name="HitHighlighting"> <xsl:with-param name="hh" select="hithighlightedproperties/HHTitle" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="title"/> </xsl:otherwise> </xsl:choose> </a>

     `<xsl:template name="substring-before-last">
     <!--passed template parameter -->
     <xsl:param name="list"/>
     <xsl:param name="delimiter"/>
        <xsl:choose>
            <xsl:when test="contains($list, $delimiter)">
            <!-- get everything in front of the first delimiter -->
            <xsl:value-of select="substring-before($list,$delimiter)"/>
        <xsl:choose>
            <xsl:when test="contains(substring-after($list,$delimiter),$delimiter)">
            <xsl:value-of select="$delimiter"/>
            </xsl:when>
            </xsl:choose>
            <xsl:call-template name="substring-before-last">
            <!-- store anything left in another variable -->
            <xsl:with-param name="list" select="substring-after($list,$delimiter)"/>
            <xsl:with-param name="delimiter" select="$delimiter"/>
        </xsl:call-template>
    </xsl:when>
</xsl:choose>

`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.