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. Ubuntu · Docker —— 从入门到实践

      https://yeasy.gitbooks.io/docker_practice/appendix/repo/ubuntu.html#1604-%E7%89%88%E6%9C%AC

  2. 【转】Java类成员变量默认初始化规则

    一个变量作为类成员使用的时候,如果没有被初始化,java会为其分配默认值: -------------------------------------------------------------- ...

  3. 微信小程序开发需要注意的29个坑

    1.小程序名称可以由中文.数字.英文.长度在3-20个字符之间,一个中文字等于2个字符. 2.小程序名称不得与公众平台已有的订阅号.服务号重复.如提示重名,请更换名称进行设置. 3.小程序名称在帐号信 ...

  4. 通过WinAPI播放PCM声音

    在Windows平台上,播放PCM声音使用的API通常有如下两种. waveOut and waveIn:传统的音频MMEAPI,也是使用的最多的 xAudio2:C++/COM API,主要针对游戏 ...

  5. gitblit无法安装windows服务或者启动服务失败:Failed creating java

    gitblit解压后,命令行运行installService.cmd之前,需要修改里面的参数,将ARCH修改x86,默认是amd64,我的机器是windows 10 Pro 64位版本,jdk也都是6 ...

  6. 利用kettle组件导入excel文件到数据库

    利用kettle组件导入excel文件到数据库 1.     实现目标 把excel文件内容导入到目标表中:然后用java调用kettle的转换.excel文件的内容仅仅有两列,示比例如以下: wat ...

  7. dbMigration .NET 数据同步迁移工具

    官网:http://fishcodelib.com/DBMigration.htm

  8. Android 模拟器设置

    这几个图标你应该是没有见过的,我来简单为你介绍下.最左边的图标其实你已经比较熟悉了,就是你睡觉前使用过的Android SDK管理器,点击它和点击SDK Manager效果是一样的.中间的图标是用来开 ...

  9. npm WARN saveError ENOENT: no such file or directory

    转自树之名原文npm WARN saveError ENOENT: no such file or directory解决 我是在安装sequelize时出错的.提示的错误没有保存,类似于参考的文章中 ...

  10. 【python】python彻底卸载的方法【windows安装版卸载的示例】

    要想彻底干净的卸载python,如果是使用的安装版的话,其实很简单.[windows安装版] 就是点击安装包. 例如,当前你安装的版本是3.6.5,你想要把它卸载掉. 查看python版本的命令: 只 ...