XQuery – Custom Functions
XQuery provides the capability to write custom functions. Listed below are the guidelines to create a custom function. Use the keyword declare function to define a function.Use the data types defined in…
XQuery provides the capability to write custom functions. Listed below are the guidelines to create a custom function. Use the keyword declare function to define a function.Use the data types defined in…
XQuery provides a very useful if-then-else construct to check the validity of the input values passed. Given below is the syntax of the if-then-else construct. Syntax if (condition) then ...…
Following is the list of commonly used regular expression functions provided by XQuery Sr.NoName & Description1matches Function Returns true if the input matches with the provided regular expression.2replace Function Replaces…
The tokenize function returns a sequence of items matching the regular expression. Syntax tokenize($input, $regex) Input Parameters $input − input string.$regex − regular expression. Example XQuery Expression let $input := 'Chapter 1 ... Chapter…
The replace function replaces the matched input string with a given string. Syntax replace($input, $regex, $string) Input Parameters $input − input string.$regex − regular expression.$string - string to replace original string. Example XQuery Expression let…
The matches function returns true if the input matches with the provided regular expression; otherwise false. Syntax matches($input, $regex) Input Parameters $input − input string.$regex − regular expression. Example XQuery Expression let $input :=…
The following table lists the commonly used date functions provided by XQuery. Sr.NoName & Description1current-date Function Returns the current date.2current-time Function Returns the current time.3current-dateTime Function Returns both the current…
The current-dateTime function is used to return the current date and time. Syntax current-dateTime() Example XQuery Expression let $datetime := current-dateTime() return <results> <datetime>{$datetime}</datetime> </results> Output <results> <datetime>2014-10-27T14:55:58.621+05:30</datetime>result </results> Here T separates…
The current-time function is used to return the current time. Syntax current-time() Example XQuery Expression let $time := current-time() return <results> <time>{$time}</time> </results> Output <results> <time>14:53:46.803+05:30</time> </results> Verify the Result In order…
The current-date function is used to return the current date. Syntax current-date() Example XQuery Expression let $date := current-date() return <results> <date>{$date}</date> </results> Output <results> <date>2014-10-27+05:30</date> </results> Here +5:30 is the relative…