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. 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, https://www.altova.com/xslt-extensions, 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 case-sensitive 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 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.
|
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 case-sensitive 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 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.
|
altova: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 altova:find-first, and the iteration stops.
|
altova: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 altova:find-first-combination. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:find-first-combination returns No results; (ii) The result of altova:find-first-combination will always be a pair of items (of any datatype) or no item at all.
|
altova: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 altova:find-first-pair. Note that: (i) If the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:find-first-pair returns No results; (ii) The result of altova:find-first-pair will always be a pair of items (of any datatype) or no item at all.
|
altova: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 altova:find-first-pair-pos. Note that if the Condition function iterates through the submitted argument pairs and does not once evaluate to true(), then altova:find-first-pair-pos returns No results.
|
altova: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 altova:find-first-pos, and the iteration stops.
|
altova: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.
|
altova: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).
|
altova: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.
|
altova: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.
|