本文所描述的所有函数为XForms 1.1所提供的xpath函数,这些函数只能在GForms的xpath编辑器中可用,这样才能在运行时识别并执行。
不可在XMLUtil、标准XML DOM中使用这些函数。
GForms平台提供xpath编辑器,该编辑器可以协助开发者完成大多数xpath表达式开发:
1、节点函数
1.1、instance函数
node-set instance(string?)
An XForms Model can contain more than one instance. This functionallows access to instance data, within the same XForms Model, but outside theinstance data containing the context node.
If the argument is omitted or is equal to the empty string, thenthe root element node (also called the document element node) is returned forthe default instance in the model that contains the current context node.
Otherwise, the argument is converted to a string as if by a callto the string function. This string is treated as an IDREF, which is matchedagainst instance elements in the containing document. If a match is located, andthe matching instance data is associated with the same XForms Model as thecurrent context node, this function returns a node-set containing just the rootelement node (also called the document element node) of the referenced instancedata. In all other cases, an empty node-set is returned.
Example:
For instance data corresponding to this XML:
<xforms:instancexmlns="" id="orderform">
<orderForm>
<shipTo>
<firstName>John</firstName>
</shipTo>
</orderForm>
</xforms:instance>
The following expression selects the firstName node. Note that the instance function returns an elementnode, effectively replacing the leftmost location step from the path:
ref="instance('orderform')/shipTo/firstName"
2、字符串函数
2.1、if函数
string if(boolean, string, string)
Function if evaluates the first parameter as boolean, returning the secondparameter when true, otherwise the third parameter.
2.2、property函数
string property(string)
This function accepts a string identifying a property name. If theproperty name is not recognized, empty string is returned. The propertydefinitions for this function are as follows:
Property |
Return Value |
version |
1.1 |
conformance-level |
full, basic or a string beginning with full or basic |
Any |