当前位置: 首页 > 网络学院 > XML相关教程 > XForms > XForms 函数
XForms has some predefined functions. But you can also call functions defined in scripts.
XForms包含一些预定义函数,当然,你也可以调用在脚本程序中定义的函数。
The XForms function library includes the entire XPath 1.0 core function library.
XForms函数库包含了整个 XPath 1.0 核心函数库。
XPath 1.0中心函数库的函数可在这里找到:
http://www.ruanchen.com/learn/view/doc/xpath_functions/
The following table lists the additional functions within XForms:
下面的表格列举了在XForms里的附加函数:
Function 函数 | Description 描述 |
---|---|
boolean-from-string(string) 逻辑值—字符串(字符串) | Returns true if the parameter string is "true" or "1" and false if the parameter string is "false" or "0" 参数字符串为"true" 或"1"则返回“真”,参数字符串为"false" 或"0"则返回“假” |
if(booleantest, string1, string2) (逻辑测试值,字符串1,字符串2) | Evaluates the Booleantest parameter and returns string1 if the test is true, and string2 if the test is false 计算逻辑测试(Booleantest)参数值,如果参数为真,则返回string1(字符串1);如果为假,则返回string2(字符串2) |
avg(node-set) 平均值(节点集) | Returns the average of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN 返回在指定的节点集内所有节点的平均值。每个节点的值都将被转化成一个数字。如果节点集为空则返回NaN <values> avg(/values/value) Returns: 20返回:20 |
min(node-set) 最小(节点集) | Returns the minimum value of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN 返回在指定的节点集里的最小节点值,每个节点值都将被转化成一个数字。如果节点集为空则返回NaN <values> min(/values/value) Returns: 0返回:0 |
max(node-set) 最大(节点集) | Returns the maximum value of all the nodes in the specified node-set. The value of each node is converted to a number. If the node-set is empty it returns NaN 返回在指定的节点集里的最大节点值,每个节点的值都将被转化成一个数字。如果节点集为空就返回NaN <values> max(/values/value) Returns: 20返回:20 |
count-non-empty(node-set) 非空节点个数(节点集) | Returns the number of non-empty nodes in the specified node-set 返回在指定的节点集内的非空节点的个数 <values> count-non-empty(/values/value) Returns: 3返回:3 |
index(string) 索引(字符串) | Returns the current index for a given repeat set 为一个给定的repeat集返回一个当前索引值 |
property(string) 属性(字符串) | Returns the property named by the string parameter 输出以字符串参数命名的属性:
|
now() 当前时间() | Returns the current system date and time in xs:dateTime format 以xs:dateTime格式返回当前的系统日期和时间 |
instance(string) 情况(字符串) | An XForms Model can contain more than one instance. This function returns the root node of the specified instance data XForms模式可以包含多个实例。该函数返回指定实例数据的根节点: <xforms:instance id="orderform"> ref="instance('orderform')/firstName" This example returns a node-set that consists of the firstName element node from the instance named "orderform" |
days-from-date(string) 天数(字符串) | If the string parameter represents a legal xs:date or xs:dateTime, it returns the number of days between the specified date and 1970-01-01, otherwise it returns NaN 如果字符串参数是合法的xs:date 或xs:dateTime,则返回从指定日期开始,到1970-01-01之间的天数,否则返回NaN days-from-date("2002-01-02") returns 11689 |
seconds-from-dateTime(string) | If the string parameter represents a legal xs:dateTime, it returns the number of seconds between the specified dateTime and 1970-01-01T00:00:00Z, otherwise it returns NaN 如果字符串参数是合法的xs:dateTime,则返回从指定的时间日期开始,到1970-01-01T00:00:00Z的秒数,否则返回NaN |
seconds(string) 秒数(字符串) | If the string parameter represents a legal xs:duration, it returns the number specified in the seconds component plus 60 * the number specified in the minutes component, plus 60 * 60 * the number specified in the hours component, plus 60 * 60 * 24 * the number specified in the days component, otherwise it returns NaN 如果字符参数是合法的xs:duration,则返回:秒数+分钟数*60+小时数*60*60+天数*60*60*24,否则返回NaN?? seconds("P1Y2M") returns 0 |
months(string) 月数(字符串) | If the string parameter represents a legal xs:duration, it returns the number specified in the months component plus 12 * the number specified in the years component, otherwise it returns NaN 如果字符参数是合法的xs:duration,则返回:月数+年数*12,否则返回NaN months("P1Y2M") returns 14 |