Files
release11-tools/FunctionSet/XPath/1+2Examples

122 lines
12 KiB
Plaintext

!function;param?desc?param?desc...;expression?result?expression?result
fn:last();current context node?Returns context size in expression context;
fn:position();current context node?Returns possition of current context node in expression context;
fn:count(node-set);node-set?Node-set to count nodes in;count(//b:book)?5?count(//person[@id>5])?17
fn:id(object);if nodeset?string value of each node in the node-set is treated as an id?if string?treated as a space-separated list of ids;
fn:local-name(node-set);node-set?Extract first node and return its local name;local-name(//b:books)?b:book?local-name(//b:book)?b:title
fn:local-name();current context node?Extract first node and return its local name;
fn:namespace-uri(node-set);node-set?Extract first node and return the namespace URI;namespace-uri(//b:book)?http://www.book.com?
fn:namespace-uri();current context node?Extract first node and return the namespace URI;
fn:name(node-set);node-set?Extract first node and return QName;name(//b:books/*)?b:book?name(//b:book/*)?b:title
fn:name();;current context node?Extract first node and return QName;
fn:string(object);string?The object to convert to a string;string((1<0))?false?string(.11)?0.11
fn:string();current context node?Converts current context node to string
fn:concat(string, string, string*);string?String to be merged?string?String to be merged?string*?any number of strings;concat("aa","bb")?aabb?concat("aa", 123)?aa123
fn:starts-with(string, string);string?String to be searched?string?String to be found;starts-with("aabb", "aa")?true?starts-with("aabb", "cc")?false
fn:contains(string, string);string?String to be searched?string?String to be found;contains("abc", "c")?true?contains("abc", "1")?false
fn:substring-before(string, string);string?String to be searched?string?String to be used to split;substring-before("aabbcc","bb")?aa?substring-before("aabbcc","c")?aabb
fn:substring-after(string, string);string?String to be searched?string?String to be used to split;substring-after("aabbcc","bb")?cc?substring-after("aabbcc","a")?abbcc
fn:substring(string, number, number);string?String to be cut?integer?Starting position?integer?Length of the substring;substring("aabbcc", 1, 2)?aa
fn:substring(string, number);string?String to be cut?integer?Starting position?;substring("aabbcc", 3)?bbcc
fn:string-length(string);string?String of which length should be returned;string-length("aabbcc")?6?string-length("aa bb cc")?8
fn:string-length();current context node?Converts current node to string and returns length;
fn:normalize-space(string);string?String to be normalized;normalize-space("aa bb cc")?aa bb cc?normalize-space("aa bb cc")?aa bb cc
fn:normalize-space();current context node?Converts current node to string and performs normalization;
fn:translate(string, string, string);string?String to be edited?string?sequence of characters to be replaced?string?sequence of character to be used in replacement;translate("aabbcc", "ab","xz")?xxzzcc?translate("Test sequence", "e","z")?Tzst szquzncz
fn:boolean(object);expression?The expression to be evaluated;boolean(1>2)?false?boolean("a"="a")?true
fn:not(boolean);boolean?Boolean value to be inverted;not("a"="a")?false?not(true)?false
fn:true();?Returns boolean value true;true()?true
fn:false();?Returns boolean value false;false()?false
fn:lang(string);string?Checks if the context node matches given language;(context: <data xml:lang="en"/>): lang('en')?true?(context: <data xml:lang="en-US"/>): lang('en')?true?(context: <data xml:lang="de"/>): lang('en')?false
fn:number(object);object?Converts given object to a number;number(true())?1?number(false())?0?number("55")?55?number(" 55 ")?55
fn:number();current context node?Converts current context node to a number;number(true())?1?number(false())?0?number("55")?55?number(" 55 ")?55
fn:sum(node-set);node-set?Summs each node from the set passed through number() function;
fn:floor(number);number?Decimal number to be converted to integer;floor(3.1)?3?floor(3.99)?3
fn:ceiling(number);number?Decimal number to be converted to integer;ceiling(3.1)?4?ceiling(3.99)?4
fn:round(number);number?Decimal number to be converted to integer;round(3.1)?3?round(3.6)?4
fn:timezone-from-dateTime(datetime);datetime?DateTime to extract fimezone information from;timezone-from-dateTime(xs:dateTime("2021-01-15T12:10:00-03:00"))?-PT3H
fn:year-from-dateTime(datetime);datetime?datetime to extract years component from;year-from-dateTime(xs:dateTime("2011-11-15T12:30-04:10"))?2011
fn:month-from-dateTime(datetime);datetime?datetime to extract month component from;month-from-dateTime(xs:dateTime("2011-11-15T12:30-04:10"))?11
fn:day-from-dateTime(datetime);datetime?datetime to extract day component from;day-from-dateTime(xs:dateTime("2011-11-15T12:30-04:10"))?15
fn:hours-from-dateTime(datetime);datetime?datetime to extract hours component from;hours-from-dateTime(xs:dateTime("2011-11-15T12:30-04:10"))?12
fn:minutes-from-dateTime(datetime);datetime?datetime to extract minutes component from;minutes-from-dateTime(xs:dateTime("2011-11-15T12:30-04:10"))?30
fn:seconds-from-dateTime(datetime);datetime?datetime to extract seconds component from;seconds-from-dateTime(xs:dateTime("2011-11-15T12:30:00-04:10"))?0
fn:hours-from-time(time);time?time to extact hours component from;hours-from-time(xs:time("10:22:00"))?10
fn:minutes-from-time(time);time?time to extract minutes component from;minutes-from-time(xs:time("10:22:00"))?22
fn:seconds-from-time(time);time?Time to convert to seconds;seconds-from-time(xs:time("10:22:00"))?0
fn:year-from-date(date);date?date to extract years component from;year-from-date(xs:date("2011-11-15"))?2011
fn:month-from-date(date);date?Date to extrat the month from;month-from-date(xs:date("2011-11-15"))?11
fn:day-from-date(date);date?date to extact day component from;day-from-date(xs:date("2011-04-23"))?23
fn:current-time();;current-time()?11:48:04.393361+01:00
fn:current-date();current-date()?2021-03-25+01:00
fn:current-dateTime();;current-dateTime()?2021-03-24T18:15:09.808+01:00
fn:dateTime(date,time);date?date to be merged into dateTime?time?time to be merged into dateTime;dateTime(xs:date("2011-11-15"), xs:time("10:22:00"))?2011-11-15T10:22:00
fn:timezone-from-time(time);time?time to extract timezone infromation from;timezone-from-time(xs:time("10:22:00+10:00"))?PT10H
fn:implicit-timezone();;implicit-timezone()?PT1H
fn:years-from-duration(datetimedur);datetimedur?datetimedur to extract years component from;years-from-duration(xs:duration("P5Y2DT10H59M"))?5
fn:months-from-duration(datetimedur);datetimedur?datetimedur to extract months component from;months-from-duration(xs:duration("P5Y10M2DT10H59M"))?10
fn:days-from-duration(datetimedur);datetimedur?datetimedur to extract days component from;days-from-duration(xs:duration("P5Y2DT10H59M"))?2
fn:hours-from-duration(datetimedur);datetimedur?datetimedur to extract hours component from;hours-from-duration(xs:duration("P5Y2DT10H59M"))?10
fn:minutes-from-duration(datetimedur);datetimedur?datetimedur to extract minute component from;years-from-duration(xs:duration("P5Y2DT10H59M"))?59
fn:seconds-from-duration(datetimedur);datetimedur?datetimedur to extract seconds component from;days-from-duration(xs:duration("P5Y2DT10H59M40S"))?40
fn:adjust-dateTime-to-timezone(datetime,timezone);datetime?datetime to be adjusted?timezone?timezone to be used in provided date;adjust-dateTime-to-timezone(xs:dateTime('2011-11-15T12:30:00-04:10'), xs:dayTimeDuration("PT10H"))?2011-11-16T02:40:00+10:00
fn:adjust-date-to-timezone(date,timezone);date?date to be adjusted?timezone?timezone to be imposed into date;adjust-date-to-timezone(xs:date('2011-11-15'), xs:dayTimeDuration("PT10H"))?2011-11-15+10:00
fn:timezone-from-date(date);date?date to extract timezone information from;timezone-from-date(xs:date("2011-11-15+11:00"))?PT1H?timezone-from-date(xs:date("2011-11-15+11:00"))?PT11H
fn:adjust-time-to-timezone(time,timezone);time?time to be adjusted?dayTimeDuration?timezone to be appended?adjust-time-to-timezone(xs:time("12:30:00"),xs:dayTimeDuration("PT11H"))?12:30:00+11:00
!SEQUENCE
fn:data(item.item,...);sequence*?sequence to be split to atomic values;data((1,2,23, "test"))?1 2 23 test
fn:insert-before((item,item,...),pos,inserts);Returns a new sequence constructed from the value of the item arguments
fn:min((arg,arg,...));sequence*?sequence to select minimum from;min((1,2,3))?1?min(('a', 'k'))?'a'
fn:avg((arg,arg,...));sequence*?returns average value of provided elements;avg((1,2,3))?2
fn:max((arg,arg,...));sequence*?sequence to select maximum from;max((1,2,3))?3?max(('a', 'k'))?'k'
fn:exactly-one(item,item,...);sequence?sequence to check;exactly-one((1))?1?exactly-one((1,1))?fn:exactly-one called with a sequence containing zero or more than one item.
fn:one-or-more(item,item,...);sequence?sequence to check;one-or-more((1, 2, 3))?1 2 3?one-or-more()?An empty sequence is not allowed as the first argument of fn:one-or-more()
fn:empty(item,item,...);sequence?sequence to check?empty(())?true?empty((1))?false?empty((1,2,3))?false
fn:distinct-values((item,item,...),collation);sequence?sequence to extract distinct values from;distinct-values((1, 2, 3, 1, 2))?(1, 2, 3)
fn:exists(item,item,...);Returns true if the value of the arguments IS NOT an empty sequence, otherwise it returns false?exists(remove(("ab"), 1))?false
!STRING
fn:upper-case(string);string?string to be converted to upper case;upper-case('aabbCC')?'AABBCC'
fn:lower-case(string);string?string to be converted to upper case;lower-case('aabbCC')?'aabbcc'
fn:string-join((string,string,...),sep);string*?string sequence to be joined?string?separator to be used;string-join(('fox', 'jumps', 'over', 'dog'), ' ')?' fox jumps over dog '?string-join(('fox', 'jumps', 'over', 'dog'))?'joxjumpsoverdog'
fn:string-to-codepoints(string);string?string to be coverted to list of unicode values;string-to-codepoints("test")?(116, 101, 115, 116)
fn:codepoints-to-string((int,int,...));int*?int sequence to be converted to string;codepoints-to-string((116, 101, 115, 116))?'test'
fn:compare(comp1,comp2);string?first parameter to be compared?string?second parameter to be compared;compare('abc', 'abc')?0?compare('abc', 'abd')?-1?compare('abc1', 'abd')?-1?compare("abc1","abc")?1
fn:compare(comp1,comp2,collation);string?first parameter to be compared?string?second parameter to be compared?string?collation to be used in comparison(letter weight may differ between languages);compare('ghi', 'ghi')?0
!NUMBER
fn:deep-equal(param1,param2,collation);
fn:default-collation();;
fn:codepoint-equal(comp1,comp2);int?unicode codepoint?int?unicode codepoint;codepoint-equal(111, 111)?true?codepoint-equal(111, 112)?false?codepoint-equal("111F", "111F")?true
fn:node-name(node);node?node to retrieve QName from;
fn:remove((item,item,...),position);sequence*?sequence to be modified?integer?position to insert element from;remove(("a","b","c"), 1)?b c?remove(("a","b","c"), 0)?a b c
fn:insert-before((item,item,...),position,inserts);sequence*?sequence to be modified?integer?position to insert items to?sequence*?sequence to be inserted?insert-before(("a","b","c"), 2 ,("xx"))?a xx b c
fn:reverse((item,item,...));sequence*?sequence of elements to have its order reversed;reverse(("ab", "cd", "ef"))?("ef", "cd", "ab")?reverse(("ab"))?("ab")
fn:static-base-uri();;default-collation()?http://www.w3.org/2005/xpath-functions/collation/codepoint
fn:root(node);node?node return root from;
fn:tokenize(string,pattern);string?string to be tokenized?string?string to be used to split the first argument;tokenize("fox jumps over dog", "\s+")?("fox", "jumps", "over", "dog")
fn:round-half-to-even(number);number?number to be rounded to nearest whole number;round-half-to-even(0.5)?0?round-half-to-even(1.5)?2?round-half-to-even(2.5)?2
fn:round-half-to-even(number, precision);number?number to be rounded to nearest whole number?number?precision to be used during rounding;round-half-to-even(1.54, 1)?1.5?
fn:abs(num);number?number to be converted to absolute value;abs(5)?5?abs(-5)?5
fn:matches(string,pattern);string?string to search in?string?pattern to be found;matches("Xpath", "pat")?true?matches("Xpath", "abc")?false
fn:document-uri(node);