| 名稱 |
說明 |
| fn:string(arg) |
返回參數的字串值。參數可以是數字、邏輯值或節點集。 例子:string(314) 結果:"314" |
| fn:codepoints-to-string(int,int,...) |
根據代碼點序列返回字串。 例子:codepoints-to-string(84, 104, 233, 114, 232, 115, 101) 結果:'Thérèse' |
| fn:string-to-codepoints(string) |
根據字串傳回碼點序列。 例子:string-to-codepoints("Thérèse") 結果:84, 104, 233, 114, 232, 115, 101 |
| fn:codepoint-equal(comp1,comp2) |
根據 Unicode 代碼點對照,如果 comp1 的值等於 comp2 的值,則返回 true。(http://www.w3.org/2005/02/xpath-functions/collation/codepoint),否則返回 false。 |
- fn:compare(comp1,comp2)
- fn:compare(comp1,comp2,collation)
|
如果 comp1 小於 comp2,則返回 -1。如果 comp1 等於 comp2,則返回 0。如果 comp1 大於 comp2,則返回 1。(根據所用的對照規則)。 例子:compare('ghi', 'ghi') 結果:0 |
| fn:concat(string,string,...) |
返回字串的拼接。 例子:concat('XPath ','is ','FUN!') 結果:'XPath is FUN!' |
| fn:string-join((string,string,...),sep) |
使用 sep 參數作為分隔字元,來返回 string 參數拼接後的字串。 例子:string-join(('We', 'are', 'having', 'fun!'), ' ') 結果:' We are having fun! ' 例子:string-join(('We', 'are', 'having', 'fun!')) 結果:'Wearehavingfun!' 例子:string-join((), 'sep') 結果:'' |
- fn:substring(string,start,len)
- fn:substring(string,start)
|
返回從 start 位置開始的指定長度的子字串。第一個字元的下標是 1。如果省略 len 參數,則返回從位置 start 到字串末尾的子字串。 例子:substring('Beatles',1,4) 結果:'Beat' 例子:substring('Beatles',2) 結果:'eatles' |
| fn:string-length(string) fn:string-length() |
返回指定字串的長度。如果沒有 string 參數,則返回當前節點的字串值的長度。 例子:string-length('Beatles') 結果:7 |
- fn:normalize-space(string)
- fn:normalize-space()
|
刪除指定字串的開頭和結尾的空白,並把內部的所有空白序列替換為一個,然後返回結果。如果沒有 string 參數,則處理當前節點。 例子:normalize-space(' The XML ') 結果:'The XML' |
- fn:normalize-unicode()
- fn:upper-case(string)
|
把 string 參數轉換為大寫。 例子:upper-case('The XML') 結果:'THE XML' |
| fn:lower-case(string) |
把 string 參數轉換為小寫。 例子:lower-case('The XML') 結果:'the xml' |
| fn:translate(string1,string2,string3) |
把 string1 中的 string2 替換為 string3。 例子:translate('12:30','30','45') 結果:'12:45' 例子:translate('12:30','03','54') 結果:'12:45' 例子:translate('12:30','0123','abcd') 結果:'bc:da' |
| fn:escape-uri(stringURI,esc-res) |
例子:escape-uri("http://example.com/test#car", true()) 結果:"http%3A%2F%2Fexample.com%2Ftest#car" 例子:escape-uri("http://example.com/test#car", false()) 結果:"http://example.com/test#car" 例子:escape-uri ("http://example.com/~bébé", false()) 結果:"http://example.com/~b%C3%A9b%C3%A9" |
| fn:contains(string1,string2) |
如果 string1 包含 string2,則返回 true,否則返回 false。 例子:contains('XML','XM') 結果:true |
| fn:starts-with(string1,string2) |
如果 string1 以 string2 開始,則返回 true,否則返回 false。 例子:starts-with('XML','X') 結果:true |
| fn:ends-with(string1,string2) |
如果 string1 以 string2 結尾,則返回 true,否則返回 false。 例子:ends-with('XML','X') 結果:false |
| fn:substring-before(string1,string2) |
返回 string2 在 string1 中出現之前的子字串。 例子:substring-before('12/10','/') 結果:'12' |
| fn:substring-after(string1,string2) |
返回 string2 在 string1 中出現之後的子字串。 例子:substring-after('12/10','/') 結果:'10' |
| fn:matches(string,pattern) |
如果 string 參數匹配指定的模式,則返回 true,否則返回 false。 例子:matches("Merano", "ran") 結果:true |
| fn:replace(string,pattern,replace) |
把指定的模式替換為 replace 參數,並返回結果。 例子:replace("Bella Italia", "l", "*") 結果:'Be**a Ita*ia' 例子:replace("Bella Italia", "l", "") 結果:'Bea Itaia' |
| fn:tokenize(string,pattern) |
例子:tokenize("XPath is fun", "/s+") 結果:("XPath", "is", "fun") |