xslt中的常用函数

在我们制作标签的时候经常要使用到一些xslt的知识,以下整理了常用的xslt函数供大家使用。

常用字符串函数:
contains('Welcome','e'):字符串包含,包含:true,不包含:false


concat('Welcome','Name','!’):返回字符串的拼接。
例子:concat('XPath','is ','FUN!')结果:'XPath is FUN!'


substring-before(string1, string2):返回 string2 在 string1 中出现之前的子字符串。


substring-after(string1,string2):返回 string2 在 string1 中出现之后的子字符串。

 
starts-with(string1, string2):如果 string1 以 string2 开始,则返回 true,否则返回 false


substring(string,start,len):返回从 start 位置开始的指定长度的子字符串。第一个字符的下标是 1。如果省略 len 参数,则返回从位置 start 到字符串末尾的子字符串。

string-length(string):返回指定字符串的长度。如果没有 string 参数,则返回当前节点的字符串值的长度。

translate(string, from-pattern, to-pattern)把 string1 中的 string2 替换为 string3。

大小写转换妙用:
大小写转换:translate('Hello','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz');

原文地址:https://www.cnblogs.com/cRaZy-TyKeIo/p/3473221.html