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. DG449 High Voltage Single SPDT Analog Switch in SOT23-8

    DESCRIPTION The DG449 is a dual supply single-pole/double-throw (SPDT) switches. On resistance is 38 ...

  2. SAE J1850 VPW Implement

    ---恢复内容开始--- OBDII Interface Project When I can ever find enough time away from schoolwork, I try to ...

  3. STM32F103ZET6 用定时器级联方式输出特定数目的PWM

    STM32F103ZET6 用定时器级联方式输出特定数目的PWM STM32F103ZET6里共有8个定时器,其中高级定时器有TIM1-TIM5.TIM8,共6个. 这里需要使用定时器的级联功能,ST ...

  4. 使用cwRsync实现windows下文件定时同步

    1.参考文献: 使用cwRsync实现windows下文件定时同步(备份) 文件同步工具CwRsync的使用方法及常用命令详解 2.背景: 当前的SCADA架构中,有1台Server,5台FE,还有1 ...

  5. C++ classes and uniform initialization

     // classes and uniform initialization #include <iostream> using namespace std; class Circle ...

  6. IEnumerable是集合,IEnumerator是集合的迭代器

    我们常用IEnumerable,却忽视IEnumerator.简单来说,IEnumerable是可以被循环遍历的集合,IEnumerator实施循环遍历. 接口分别是: public interfac ...

  7. libxml2.dylb 罗致<libxml/tree.h> 老是找不到头文件

    libxml2.dylb 导致<libxml/tree.h> 老是找不到头文件 添加了libxml2.dylb的framework ,结果还是引用不了<libxml/tree.h&g ...

  8. 【ELK】4.spring boot 2.X集成ES spring-data-ES 进行CRUD操作 完整版+kibana管理ES的index操作

    spring boot 2.X集成ES 进行CRUD操作  完整版 内容包括: ============================================================ ...

  9. Java加密技术(一)——加密介绍

    from://http://blog.csdn.net/janronehoo/article/details/7590772 如基本的单向加密算法: BASE64 严格地说,属于编码格式,而非加密算法 ...

  10. linux配置nginx

    相关命令: nginx -s reload  :修改配置后重新加载生效 nginx -s reopen  :重新打开日志文件nginx -t -c /path/to/nginx.conf 测试ngin ...