XPath sequence five

xiaoxiao2021-03-06  89

5 function call

Another important expression in XPath is a function call. XPath defines a core function library that the function of this library must be supported in advance.

All functions in the library belong to non-namespaces, so their names do not require a namespace prefix. XPath can increase this core function library with appropriate expansion, and the expanded function name must be a definition name with a namespace prefix. The following classification describes the functions in the core function library.

Each of the functions in the library uses a function prototype, the prototype gives the return type, the name of the function, and the type of parameters. If the parameter type follows a question mark, the parameter is optional; otherwise, the parameter must be.

(1) Node collection function

Number last ()

Description: Returns the number of nodes in the context node sequence.

Number position ()

Description: The Position function returns a number, which is equal to the index value of the context node in the context.

Number Count (Node-Set)

Description: The count function returns the number of nodes in the parameter node-set.

Node-set ID (Object)

Description: The id function selects an element through a unique ID. When the parameter of the ID is a node collection type, the result is a merger of the result of the string value of each node in the parameter node collection. When the parameter of the ID is any other type, the parameter is first converted into a string, as in calling the String function, the string is split into a list of helins separated by the blank grid. The result is a collection of elements nodes in the same document equal to any one of the aids in the list.

String Local-name (Node-set?)

Description: The function local-name returns a local part of the extension of a node that is the first node in the parameter node set. If the parameter node collection is empty or the first node does not have an extension, an empty string is returned. If the parameters are omitted, it defaults the context node as the unique member of the node set.

String namespace-uri (node-set?)

Description: Function Namespace-URI Returns the namespace URI of the extension of the first node in the parameter node collection. If the parameter node collection is empty, the first node has no extension, or the namespace URI of the extension is empty, then an empty string is returned. If the parameters are omitted, it defaults the context node as the unique member of the node set.

String name (node-set?)

Description: The function name returns a string, and the string contains a QNAME that returns the extension of the first node in the parameter node collection according to the document order. Returns an empty string if the parameter node collection is empty or the first node does not have an extension. If it omits the parameters, the context node is the only member of the node set by default.

(2) String function

String String (Object?)

Description: The string function converts the object according to the following points into characters:

• If it is a node set, return a string value of the first node under the document order in the node collection, and return the empty string if the node set is empty.

· Digitally converted into characters as follows

o nan converted into string nan

O positive zero converted into string 0

o Negative zero converted into string 0

o is infinite to convert into string infinity

o Negative infinity conversion into string --Infinity

o If the number is an integer, the number represents a decimal form with a non-numeric point and head zero, if the number is negative, add a negative number before it.

Otherwise, the number represents a decimal form that includes a decimal point and a number there in front of the decimal point and a number after the decimal point, if the number is negative, then add a negative number before it; except for the decimal point There is a bit of zero, there should be no header; in addition to the number of points after the decimal point, there should be many bits to distinguish between the number and all other IEEE 754 values. · Boolean fake value is converted into string False. The true value of Boole is converted into a string true.

· Not four basic types of objects convert into strings in ways to belong.

If the parameter is omitted, the default is a collection of only one context node as a member.

String cont (String, String, String *)

Description: The Concat function returns the connection of its parameters.

Boolean Starts-with (String, String)

Description: If the first string parameter starts with the second string parameter, the Starts-with function returns true, otherwise, return false.

Boolean Contains (String, String)

Description: If the first string parameter contains the second string parameter, the contAins function returns true, otherwise, return false.

String Substring-Before (String, String)

Description: The substring-before function returns a sub-string before the first string parameter appears in the second parameter, or if the first string parameter does not contain the second string parameter, return an empty string.

String subString -After (string, string)

Description: Substring -After function Returns a sub-string after the first string parameter appears for the first time, or if the first string parameter does not contain a second string parameter, return an empty string.

String Substring (String, Number, Number?)

Description: The substring function returns the first string parameter starting from the position specified by the second parameter to the sub-string of the third parameter length. If there is no third parameter, return to the position specified from the second parameter until the end.

Number string-length (String?)

Description: String-length returns the number of characters in the string. If the parameter is omitted, the string value of the context node is default.

String Normalize-Space (String?)

Description: The Normalize-Space function returns the standardized parameter string of the blank character, which is a clearance of the predecessor and the end of the predecessor and replaced a consecutive blank character with a whistle. If the parameter is omitted, the string value of the context node is default.

String Translate (String, String, String)

Description: The Translate function returns the string of the first parameter, where the characters appearing in the second parameter are replaced by the characters corresponding to the position in the third parameter. For example, Translate ("Bar", "ABC", "ABC") returns a string bar. If the character in the second parameter is in the corresponding position of the third parameter, there is no character (because the string in the second parameter is higher than the string of the third parameter), then the one in the first parameter The characters will be removed. For example, Translate ("- AAA -", "ABC -", "ABC") returns "AAA". If the characters in the second parameter appear more than once, then the first appearance determines the alternative character. If the string in the third parameter is longer than the string of the second parameter, the excess character will be ignored. (3) Boolean function

Boolean Boolean (Object)

Description: The Boolean function converts its parameters according to the following: The number is true and only when it is not a positive and negative or nan; the node collection is true and only when it is not empty; the string is true and only when it The length is not zero; it is not four basic types of objects to translate into a Boolean type in the way.

Boolean Not (Boolean)

Description: If the parameter returns true for the true NOT function, it will return false.

Boolean True ()

Description: The True function returns true.

Boolean False ()

Description: false functions return false.

Boolean Lang (String)

Description: Depending on whether the language of the context node specified by the XML: LANG attribute is consistent with the language specified by the parameter, the parameter string Lang function returns true or false. The language of the context node is determined by the XML: Lang attribute of the context node. If there is no XML: lang attribute, the XML: LANG attribute value is determined by the XML: LANG attribute value. If there is no such node, then the LANG function returns a false. If there is such a node, it is compared, regardless of case-oriented language suffixes.

(4) Digital functions

NUMBER NUMBER (Object?)

Description: Number function parameters are converted into numbers according to the following list:

· String is converted into IEEE 754 closest (according to IEEE 754 Near Rule Rule); if you cannot convert to a value, return nan

· Boolean is transformed into 1; Boolean swapped into 0

· The node set first converts into a string, and then converted according to the string parameters

· Not four basic types of objects convert into numbers in the way.

If the parameter is omitted, the default is a collection of only one context node as a member.

Number SUM (Node-Set)

Description: For each node set in the parameter node, the SUM function returns to the node string value to the sum.

Number floor (Number)

Description: The FLOOR function returns the maximum number of integers not more than the parameter.

Number CEILING (NUMBER)

Description: The CEILING function returns the minimum of the integer of the parameter.

Number Round (Number)

Description: The Round function returns an integer closest to the parameter. If there are two such numbers, then the return closest to the infinity. If the parameter is nan, then returns NAN. If the parameter is infinite, then return is infinite. If the parameter is negative, then returns to endless. If the parameter is positive and zero, then return to zero. If the parameter is a negative zero, then returns negative zero. If the parameter is less than zero, but is greater than or equal to -0.5, then returns negative zero. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ---------------

转载请注明原文地址:https://www.9cbs.com/read-122232.html

New Post(0)