Appendices > Engine information > XSLT and XPath/XQuery Functions > Altova Extension Functions XPath/XQuery Functions: Sequence 
Scroll Home Prev Top Next More 
Altova's sequence extension functions can be used in XPath and XQuery expressions and provide additional functionality for the processing of data. The functions in this section can be used with Altova's XPath 3.0 and XQuery 3.0 engines. They are available in XPath/XQuery contexts.
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. Altova extension functions are in the Altova extension functions namespace, http://www.altova.com/xsltextensions, and are indicated in this section with the prefix altova:, which is assumed to be bound to this namespace. Note that, in future versions of your product, support for a function might be discontinued or the behavior of individual functions might change. Consult the documentation of future releases for information about support for Altova extension functions in that release.

altova: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 casesensitive and conducted along the attribute:: axis. This means that the context node must be the parent element node.
altova: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 casesensitive 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.

altova: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 casesensitive and conducted along the child:: axis. The context node must be the parent node of the element/s being searched for.
altova: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 casesensitive 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.

altova:findfirst((Sequence as item()*), (Condition( SequenceItem 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 altova:findfirst, and the iteration stops.

altova:findfirstcombination((Seq01 as item()*), (Seq02 as item()*), (Condition( Seq01Item, Seq02Item as xs:boolean)) as item()* XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq01 and Seq02, 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 Seq01 and Seq02 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 Seq01 = X1, X2, X3 ... Xn And Seq02 = 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 altova:findfirstcombination. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:findfirstcombination returns No results; (ii) The result of altova:findfirstcombination will always be a pair of items (of any datatype) or no item at all.

altova:findfirstpair((Seq01 as item()*), (Seq02 as item()*), (Condition( Seq01Item, Seq02Item as xs:boolean)) as item()* XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq01 and Seq02, 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 Seq01 and Seq02 are passed in ordered pairs as the arguments of the function in Condition. The pairs are ordered as follows. If Seq01 = X1, X2, X3 ... Xn And Seq02 = 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 altova:findfirstpair. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:findfirstpair returns No results; (ii) The result of altova:findfirstpair will always be a pair of items (of any datatype) or no item at all.

altova:findfirstpairpos((Seq01 as item()*), (Seq02 as item()*), (Condition( Seq01Item, Seq02Item as xs:boolean)) as xs:integer XP3.1 XQ3.1 This function takes three arguments:
•The first two arguments, Seq01 and Seq02, 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 Seq01 and Seq02 are passed in ordered pairs as the arguments of the function in Condition. The pairs are ordered as follows. If Seq01 = X1, X2, X3 ... Xn And Seq02 = 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 altova:findfirstpairpos. Note that if the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:findfirstpairpos returns No results.

altova:findfirstpos((Sequence as item()*), (Condition( SequenceItem 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 altova:findfirstpos, and the iteration stops.

altova:foreachattributepair(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.

altova:foreachcombination(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).

altova:foreachmatchingattributepair(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.

altova:substituteempty(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.

© 20152021 Altova GmbH