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. C# WINFORM的自动更新程序

    自动更新程序AutoUpdate.exe https://git.oschina.net/victor596jm/AutoUpdate.git 1.获取源码 http://git.oschina.ne ...

  2. 基于Linux的智能家居的设计(3)

    2  硬件设计 本课题的硬件设计包含主控制器.传输数据设计.数据採集设计.控制驱动设计.显示设计.门禁设计. 2.1  主控制器 依据方案三选择S3C6410主控芯片,S3C6410是由Samsung ...

  3. BoundingBoxUV与BoundingBoxXYZ

    start UIApplication app = commandData.Application; Document doc = app.ActiveUIDocument.Document; ); ...

  4. delphi 取得任意程序的命令行

    program GetCommandLineExDemo; uses Windows; constSystemHandleInformation = 16;ProcessBasicInformatio ...

  5. Windows Phone本地数据库(SQLCE):5、[Association]attribute(翻译)(转)

    这是“windows phone mango本地数据库(sqlce)”系列短片文章的第五篇. 为了让你开始在Windows Phone Mango中使用数据库,这一系列短片文章将覆盖所有你需要知道的知 ...

  6. Spring Boot 2中对于CORS跨域访问的快速支持

    原文:https://www.jianshu.com/p/840b4f83c3b5 目前的程序开发,大部分都采用前后台分离.这样一来,就都会碰到跨域资源共享CORS的问题.Spring Boot 2 ...

  7. log4j直接输出日志到flume

    log4j.properties配置: log4j.rootLogger=INFOlog4j.category.com.besttone=INFO,flumelog4j.appender.flume ...

  8. 【工具类】怎么进入阿里云docker仓库

    进入阿里云docker仓库. 1.进入官网 2.选择 开发者  --->点击 阿里开源项目 3.选择  服务 点击代码托管.仓库 下的 容器镜像服务 4.点击进入 管理控制台 5.点击镜像搜索, ...

  9. WordPress主题开发:设置和获取浏览次数

    将以下代码放在functions.php,一个是获取阅读量,一个是设置阅读量 <?php /** * getPostViews()函数 * 功能:获取阅读数量 * 在需要显示浏览次数的位置,调用 ...

  10. ArrayList 排序方法的性能对比

    20000=>ZXP 二分法 getSeriesMinSort2(list) Time is 67000 20000=>循环 getSeriesMinSortFor(list) Time ...