When working with data view web parts or data form web parts in SharePoint, you might want to use some conditional formatting or branching logic, based on the file extention of your SharePoint item.

This xsl template returns the file extention from an URL:

<!-- Determine File Extention template -->

<xsl:template
name="get-file-extension">

    <xsl:param
name="path"/>

    <xsl:choose>

        <xsl:when
test="contains($path, '/')">

            <xsl:call-template
name="get-file-extension">

                <xsl:with-param
name="path"
select="substring-after($path, '/')"/>

            </xsl:call-template>

        </xsl:when>

        <xsl:when
test="contains($path, '.')">

            <xsl:call-template
name="get-file-extension">

                <xsl:with-param
name="path"
select="substring-after($path, '.')"/>

            </xsl:call-template>

        </xsl:when>

        <xsl:otherwise>

            <xsl:value-of
select="$path"/>

        </xsl:otherwise>

    </xsl:choose>

</xsl:template>

 

It runs recursively through the parameter "path" and returns the extention.

You can call and use it like this:

<xsl:variable
name="extension">

    <xsl:call-template
name="get-file-extension">

        <xsl:with-param
name="path"
select="@yourcolumnname"
/>

    </xsl:call-template>

</xsl:variable>

<!-- example use in branching logic -->

<xsl:choose>

    <xsl:when
test="$extension = 'pdf'">

        <!-- add your logic -->

    </xsl:when>

</xsl:choose>

 

 

From: http://morg.nl/2012/02/get-file-extention-in-xslt/

Get file extention in XSLT的更多相关文章

  1. 十三、File Translator怎么写

    ---恢复内容开始--- 1. File Translator可以将信息从maya中导入和导出. 2. 创建一个file translator需要从MPxFileTranslator继承. 3. 函数 ...

  2. xslt 和一个demo

    https://www.w3.org/1999/XSL/Transform Specifications The XSLT language has three versions which are ...

  3. xslt转换xml

    实现json--> xml --(xlst)--> xml pom依赖 <dependency> <groupId>net.sf.json-lib</grou ...

  4. Using XSLT and Open XML to Create a Word 2007 Document

    Summary: Learn how to transform XML data into a Word 2007 document by starting with an existing docu ...

  5. 类handler

    /** The handler class is the interface for dynamically loadable storage engines. Do not add ifdefs a ...

  6. 最佳vim技巧

    最佳vim技巧----------------------------------------# 信息来源----------------------------------------www.vim ...

  7. IOS UTI统一类型标识符:判断文件类型通过后缀

    今天在学习文档和数据共享中,首先讲的处理统一类型标识符UTI.第一次见,所以记下来以备之用,首先了解UTI和MIME的概念 1.同一类型标识符(Uniform Type Identifier,UTI) ...

  8. 经典弹出层Colorbox - a jQuery lightbox

    Colorbox - a jQuery lightbox A lightweight customizable lightbox plugin for jQuery Fork me on GitHub ...

  9. [Node.js]Path模块

    摘要 path模块提供了一些处理文件路径问题的工具. path模块 引入模块 var path=require("path"); 方法 1 path.normalize(p)规范化 ...

随机推荐

  1. sublime text2 用ctags插件实现方法定位(转)

    我们用sublime几乎都会首先安装这个插件,这个插件是管理插件的功能,先安装它,再安装其他插件就方便了. 点击sublime的菜单栏 view->show console :现在打开了控制台, ...

  2. getRequestURI,getRequestURL的区别(转)

    test1.jsp======================= <a href ="test.jsp?p=fuck">跳转到test2</a> test2 ...

  3. DMA : Timer Trigger Memory-to-memory mode,

    The DMA channels can also work without being triggered by a request from a peripheral. This mode is ...

  4. jQuery $('div>ul') $('div ul'

    $('div>ul')是<div>的直接后代里找<ul>: 而$('div ul')是在<div>的所有后代里找<ul>.

  5. 在Delphi中操作快捷方式

    快捷方式减少了系统的重复文件,是快速启动程序或打开文件或文件夹的方法,快捷方式对经常使用的程序.文件和文件夹非常有用.在Windows系统中,充斥着大量的快捷方式,那么如何操作这些快捷方式就是一个很头 ...

  6. SQL Server 2008 安装教程

    http://www.downcc.com/tech/4135.html 序列号:Developer: PTTFM-X467G-P7RH2-3Q6CG-4DMYB

  7. 实习医生风云第一至九季/全集Scrubs迅雷下载

    本季看点:<实习医生风云>一批医学院的学生来到圣心医院开始他们的实习生涯,但是从第一天起就发现这里并不是想象中安详宁静的医学圣地,从医生到护士甚至门卫个个不同寻常.内科实习医生杰迪是个聪明 ...

  8. C#设置有命令空间的属性

    之前被问到一个问题,C#中如何设置android:name这样的属性?我的第一反应是直接setAttribute不就可以了么 SetAttribute(name, value), 可事实上却不行,因为 ...

  9. cocos2d-x绑lua的开发环境

    2013年是手游开发井喷的一年,也是手游市场竞争最为激烈的一年,ios市场除了刷榜.刷榜,还是刷榜,而android有点像黑市的感觉,水太深(很多渠道商已经从上游控制了流量的入口).而cocos2d- ...

  10. Universal-Image-Loader解析(一)——ImageLoaderConfiguration的详细配置

    Universal-Image-Loader这个开源框架又来给我们造福了,它是一个图片加载框架,主要强大在于可以用于网络等图片源的加载,并且有多重缓存机制.先给出其项目地址:https://githu ...