XPath/XQuery Functions: Sequence
Altova's sequence extension functions can be used in XPath and XQuery expressions and provide additional functionality for the processing of data.
Note about naming of functions and language applicability
Altova extension functions can be used in XPath/XQuery expressions. They provide additional functionality to the functionality that is available in the standard library of XPath, XQuery, and XSLT functions. •In order to distinguish Altova extension functions from functions in the standard library, Altova extension functions are named in this documentation with a suffix of [altova:]. For example: add-years-to-date [altova:]. •When using Altova extension functions in your XPath/XQuery expressions, however, you must use the function without any prefix or suffix, just as you would use any standard XPath/XQuery function. Use an Altova extension like this: add-years-to-date(xs:date("2014-01-15"), 10).
|
attributes(AttributeName as xs:string) as attribute()* XP3.1 XQ3.1 Returns all attributes that have a local name which is the same as the name supplied in the input argument, AttributeName. The search is case-sensitive and conducted along the attribute:: axis. This means that the context node must be the parent element node.
attributes(AttributeName as xs:string, SearchOptions as xs:string) as attribute()* XP3.1 XQ3.1 Returns all attributes that have a local name which is the same as the name supplied in the input argument, AttributeName. The search is case-sensitive and conducted along the attribute:: axis. The context node must be the parent element node. The second argument is a string containing option flags. Available flags are: p = includes the namespace prefix in the search; AttributeName should then contain the namespace prefix, for example: altova:MyAttribute.
|
elements(ElementName as xs:string) as element()* XP3.1 XQ3.1 Returns all elements that have a local name which is the same as the name supplied in the input argument, ElementName. The search is case-sensitive and conducted along the child:: axis. The context node must be the parent node of the element/s being searched for.
elements(ElementName as xs:string, SearchOptions as xs:string) as element()* XP3.1 XQ3.1 Returns all elements that have a local name which is the same as the name supplied in the input argument, ElementName. The search is case-sensitive and conducted along the child:: axis. The context node must be the parent node of the element/s being searched for. The second argument is a string containing option flags. Available flags are: p = includes the namespace prefix in the search; ElementName should then contain the namespace prefix, for example: altova:MyElement.
|
find-first((Sequence as item()*), (Condition( Sequence-Item as xs:boolean)) as item()? XP3.1 XQ3.1 This function takes two arguments. The first argument is a sequence of one or more items of any datatype. The second argument, Condition, is a reference to an XPath function that takes one argument (has an arity of 1) and returns a boolean. Each item of Sequence is submitted, in turn, to the function referenced in Condition. (Remember: This function takes a single argument.) The first Sequence item that causes the function in Condition to evaluate to true() is returned as the result of find-first, and the iteration stops.
|
find-first-combination((Seq-01 as item()*), (Seq-02 as item()*), (Condition( Seq-01-Item, Seq-02-Item as xs:boolean)) as item()* XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq-01 and Seq-02, are sequences of one or more items of any datatype. •The third argument, Condition, is a reference to an XPath function that takes two arguments (has an arity of 2) and returns a boolean.
The items of Seq-01 and Seq-02 are passed in ordered pairs (one item from each sequence making up a pair) as the arguments of the function in Condition. The pairs are ordered as follows. If Seq-01 = X1, X2, X3 ... Xn And Seq-02 = Y1, Y2, Y3 ... Yn Then (X1 Y1), (X1 Y2), (X1 Y3) ... (X1 Yn), (X2 Y1), (X2 Y2) ... (Xn Yn)
The first ordered pair that causes the Condition function to evaluate to true() is returned as the result of find-first-combination. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then find-first-combination returns No results; (ii) The result of find-first-combination will always be a pair of items (of any datatype) or no item at all.
|
find-first-pair((Seq-01 as item()*), (Seq-02 as item()*), (Condition( Seq-01-Item, Seq-02-Item as xs:boolean)) as item()* XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq-01 and Seq-02, are sequences of one or more items of any datatype. •The third argument, Condition, is a reference to an XPath function that takes two arguments (has an arity of 2) and returns a boolean.
The items of Seq-01 and Seq-02 are passed in ordered pairs as the arguments of the function in Condition. The pairs are ordered as follows. If Seq-01 = X1, X2, X3 ... Xn And Seq-02 = Y1, Y2, Y3 ... Yn Then (X1 Y1), (X2 Y2), (X3 Y3) ... (Xn Yn)
The first ordered pair that causes the Condition function to evaluate to true() is returned as the result of find-first-pair. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then find-first-pair returns No results; (ii) The result of find-first-pair will always be a pair of items (of any datatype) or no item at all.
|
find-first-pair-pos((Seq-01 as item()*), (Seq-02 as item()*), (Condition( Seq-01-Item, Seq-02-Item as xs:boolean)) as xs:integer XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq-01 and Seq-02, are sequences of one or more items of any datatype. •The third argument, Condition, is a reference to an XPath function that takes two arguments (has an arity of 2) and returns a boolean.
The items of Seq-01 and Seq-02 are passed in ordered pairs as the arguments of the function in Condition. The pairs are ordered as follows. If Seq-01 = X1, X2, X3 ... Xn And Seq-02 = Y1, Y2, Y3 ... Yn Then (X1 Y1), (X2 Y2), (X3 Y3) ... (Xn Yn)
The index position of the first ordered pair that causes the Condition function to evaluate to true() is returned as the result of find-first-pair-pos. Note that if the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then find-first-pair-pos returns No results.
|
find-first-pos((Sequence as item()*), (Condition( Sequence-Item as xs:boolean)) as xs:integer XP3.1 XQ3.1 This function takes two arguments. The first argument is a sequence of one or more items of any datatype. The second argument, Condition, is a reference to an XPath function that takes one argument (has an arity of 1) and returns a boolean. Each item of Sequence is submitted, in turn, to the function referenced in Condition. (Remember: This function takes a single argument.) The first Sequence item that causes the function in Condition to evaluate to true() has its index position in Sequence returned as the result of find-first-pos, and the iteration stops.
|
for-each-attribute-pair(Seq1 as element()?, Seq2 as element()?, Function as function()) as item()* XP3.1 XQ3.1 The first two arguments identify two elements, the attributes of which are used to build attribute pairs, where one attribute of a pair is obtained from the first element and the other attribute is obtained from the second element. Attribute pairs are selected on the basis of having the same name, and the pairs are ordered alphabetically (on their names) into a set. If, for one attribute no corresponding attribute on the other element exists, then the pair is "disjoint", meaning that it consists of one member only. The function item (third argument Function) is applied separately to each pair in the sequence of pairs (joint and disjoint), resulting in an output that is a sequence of items.
|
for-each-combination(FirstSequence as item()*, SecondSequence as item()*, Function($i,$j){$i || $j} ) as item()* XP3.1 XQ3.1 The items of the two sequences in the first two arguments are combined so that each item of the first sequence is combined, in order, once with each item of the second sequence. The function given as the third argument is applied to each combination in the resulting sequence, resulting in an output that is a sequence of items (see example).
|
for-each-matching-attribute-pair(Seq1 as element()?, Seq2 as element()?, Function as function()) as item()* XP3.1 XQ3.1 The first two arguments identify two elements, the attributes of which are used to build attribute pairs, where one attribute of a pair is obtained from the first element and the other attribute is obtained from the second element. Attribute pairs are selected on the basis of having the same name, and the pairs are ordered alphabetically (on their names) into a set. If, for one attribute no corresponding attribute on the other element exists, then no pair is built. The function item (third argument Function) is applied separately to each pair in the sequence of pairs, resulting in an output that is a sequence of items.
|
substitute-empty(FirstSequence as item()*, SecondSequence as item()) as item()* XP3.1 XQ3.1 If FirstSequence is empty, returns SecondSequence. If FirstSequence is not empty, returns FirstSequence.
|