This library module provides data consolidation functions that generally take as input a sequence of XML nodes and apply some rule in order do decide which node is better suited to represent the entire sequence.
The logic contained in this module is not specific to any particular XQuery implementation, although the consolidation functions based on matching sequences against XPath expressions require some form of dynamic evaluation for XPath expressions.
all-xpaths
($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the elements from an input sequence of elements that, when matched to a given set of XPath expressions, produce a non-empty set of nodes in all the cases. |
least-attributes
($s) as element(*)
Returns the single node having the smallest number of descending attributes (attributes at any given depth) in a sequence of nodes provided as input. |
least-distinct-attributes
($s) as element(*)
Returns the single node having the smallest number of distinct descending attributes (attributes at any given depth) in a sequence of nodes provided as input. |
least-distinct-elements
($s) as element(*)
Returns the single node having the smallest number of distinct descending elements (sub-elements at any given depth) in a sequence of nodes provided as input. |
least-distinct-nodes
($s) as element(*)
Returns the single node having the smallest number of distinct descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input. |
least-elements
($s) as element(*)
Returns the single node having the smallest number of descending elements (sub-elements at any given depth) in a sequence of nodes provided as input. |
least-frequent
($s) as item()
Returns the single less frequent node in a sequence of nodes provided as input. |
least-nodes
($s) as element(*)
Returns the single node having the smallest number of descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input. |
least-similar-edit-distance
($s as xs:string*, $m as xs:string) as xs:string?
Returns the single least similar string, in terms of the edit distance metric towards an input string, in a sequence of strings provided as input. |
least-tokens
($s as xs:string*, $r as xs:string) as xs:string?
Returns the single shortest string, in terms of the number of tokens, in a sequence of strings provided as input. |
least-xpaths
($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the single element from an input sequence of elements that matches the smallest number of XPath expressions from a given set, producing a non-empty set of nodes. |
longest
($s as xs:string*) as xs:string?
Returns the single longest string, in terms of the number of characters, in a sequence of strings provided as input. |
matching
($s as xs:string*, $r as xs:string) as xs:string*
Returns the strings from an input sequence of strings that match a particular regular expression. |
most-attributes
($s) as element(*)
Returns the single node having the largest number of descending attributes (attributes at any given depth) in a sequence of nodes provided as input. |
most-distinct-attributes
($s) as element(*)
Returns the single node having the largest number of distinct descending attributes (attributes at any given depth) in a sequence of nodes provided as input. |
most-distinct-elements
($s) as element(*)
Returns the single node having the largest number of distinct descending elements (sub-elements at any given depth) in a sequence of nodes provided as input. |
most-distinct-nodes
($s) as element(*)
Returns the single node having the largest number of distinct descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input. |
most-elements
($s) as element(*)
Returns the single node having the largest number of descending elements (sub-elements at any given depth) in a sequence of nodes provided as input. |
most-frequent
($s) as item()
Returns the single most frequent node in a sequence of nodes provided as input. |
most-nodes
($s) as element(*)
Returns the single node having the largest number of descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input. |
most-similar-edit-distance
($s as xs:string*, $m as xs:string) as xs:string?
Returns the single most similar string, in terms of the edit distance metric towards an input string, in a sequence of strings provided as input. |
most-tokens
($s as xs:string*, $r as xs:string) as xs:string?
Returns the single longest string, in terms of the number of tokens, in a sequence of strings provided as input. |
most-xpaths
($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the single element from an input sequence of elements that matches the largest number of XPath expressions from a given set, producing a non-empty set of nodes. |
shortest
($s as xs:string*) as xs:string?
Returns the single shortest string, in terms of the number of characters, in a sequence of strings provided as input. |
some-xpaths
($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the elements from a sequence of elements that, when matched to a given set of XPath expressions, produce a non-empty set of nodes for some of the cases. |
superstring
($s as xs:string*) as xs:string?
Returns the single string, from an input sequence of strings, that appears more frequently as part of the other strings in the sequence. |
validating-schema
($s as element(*)*, $schema as element(*)) as element(*)*
Returns the nodes from an input sequence of nodes that validate against a given XML Schema. |
declare function con:all-xpaths($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the elements from an input sequence of elements that, when matched to a given set of XPath expressions, produce a non-empty set of nodes in all the cases.
Example usage :
all-xpaths( ( <a><b/></a>, <c><d/></c>, <d/>), (".//b") )
The function invocation in the example above returns :
(<a><b/></a>)
declare function con:least-attributes($s) as element(*)
Returns the single node having the smallest number of descending attributes (attributes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-attributes( ( <a att1="a1" att2="a2"/>, <b att1="a1" />, <c/> ) )
The function invocation in the example above returns :
(<c/>)
declare function con:least-distinct-attributes($s) as element(*)
Returns the single node having the smallest number of distinct descending attributes (attributes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-distinct-attributes( ( <a att1="a1" att2="a2"/>, <b att1="a1" />, <c/> ) )
The function invocation in the example above returns :
(<c/>)
declare function con:least-distinct-elements($s) as element(*)
Returns the single node having the smallest number of distinct descending elements (sub-elements at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-distinct-elements( ( <a><b/></a>, <b><c/></b>, <d/>) )
The function invocation in the example above returns :
(<d/>)
declare function con:least-distinct-nodes($s) as element(*)
Returns the single node having the smallest number of distinct descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-distinct-nodes( ( <a><b/></a>, <b><c/></b>, <d/>) )
The function invocation in the example above returns :
(<d/>)
declare function con:least-elements($s) as element(*)
Returns the single node having the smallest number of descending elements (sub-elements at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-elements( ( <a><b/></a>, <b><c/></b>, <d/>) )
The function invocation in the example above returns :
(<d/>)
declare function con:least-frequent($s) as item()
Returns the single less frequent node in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-frequent( ( "a", "a", "b") )
The function invocation in the example above returns :
("b")
declare function con:least-nodes($s) as element(*)
Returns the single node having the smallest number of descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
least-nodes( ( <a><b/></a>, <b><c/></b>, <d/>) )
The function invocation in the example above returns :
(<d/>)
declare function con:least-similar-edit-distance($s as xs:string*, $m as xs:string) as xs:string?
Returns the single least similar string, in terms of the edit distance metric towards an input string, in a sequence of strings provided as input. If more than one string has a minimum similarity (a maximum value for the edit distance metric), return the first string according to the order of the input sequence.
Example usage :
least-similar-edit-distance( ( "aaabbbccc", "aaabbb", "eeefff" ), "aaab" )
The function invocation in the example above returns :
( "eeefff" )
declare function con:least-tokens($s as xs:string*, $r as xs:string) as xs:string?
Returns the single shortest string, in terms of the number of tokens, in a sequence of strings provided as input.
If more then one answer is possible, return the first string according to the order of the input sequence.
Example usage :
least-tokens( ( "a b c", "a b", "a"), " +" )
The function invocation in the example above returns :
("a")
declare function con:least-xpaths($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the single element from an input sequence of elements that matches the smallest number of XPath expressions from a given set, producing a non-empty set of nodes.
If more then one answer is possible, return the first element according to the order of the input sequence.
Example usage :
least-xpaths( ( <a><b/></a>, <d><c/><b/></d>, <d/>) , (".//b", ".//c") )
The function invocation in the example above returns :
( $lt;d/> )
declare function con:longest($s as xs:string*) as xs:string?
Returns the single longest string, in terms of the number of characters, in a sequence of strings provided as input.
If more then one answer is possible, return the first string according to the order of the input sequence.
Example usage :
con:longest( ( "a", "aa", "aaa") )
The function invocation in the example above returns :
("aaa")
declare function con:matching($s as xs:string*, $r as xs:string) as xs:string*
Returns the strings from an input sequence of strings that match a particular regular expression.
Example usage :
matching( ( "a A b", "c AAA d", "e BB f"), "A+" )
The function invocation in the example above returns :
( "a A b", "c AAA d")
declare function con:most-attributes($s) as element(*)
Returns the single node having the largest number of descending attributes (attributes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-attributes( ( <a att1="a1" att2="a2"/>, <b att1="a1" />, <c/> ) )
The function invocation in the example above returns :
(<a att1="a1" att2="a2"/>)
declare function con:most-distinct-attributes($s) as element(*)
Returns the single node having the largest number of distinct descending attributes (attributes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-distinct-attributes( ( <a att1="a1" att2="a2" att3="a3"/>, <a att1="a1" att2="a2"><b att2="a2" /></a>, <c/> ) )
The function invocation in the example above returns :
(<a att1="a1" att2="a2" att3="a3"/>)
declare function con:most-distinct-elements($s) as element(*)
Returns the single node having the largest number of distinct descending elements (sub-elements at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-distinct-elements( ( <a><b/><c/><d/></a>, <a><b/><b/><c/></a>, <a/> ) )
The function invocation in the example above returns :
(<a><b/><c/><d/></a>)
declare function con:most-distinct-nodes($s) as element(*)
Returns the single node having the largest number of distinct descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-distinct-nodes( ( <a><b/></a>, <a><a/></a>, <b/>) )
The function invocation in the example above returns :
(<a><b/></a>)
declare function con:most-elements($s) as element(*)
Returns the single node having the largest number of descending elements (sub-elements at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-elements( ( <a><b/></a>, <a/>, <b/>) )
The function invocation in the example above returns :
(<a><b/></a>)
declare function con:most-frequent($s) as item()
Returns the single most frequent node in a sequence of nodes provided as input.
If more then one answer is possible, returns the first node according to the order of the input sequence.
Example usage :
most-frequent( ( "a", "a", "b") )
The function invocation in the example above returns :
("a")
declare function con:most-nodes($s) as element(*)
Returns the single node having the largest number of descending nodes (sub-nodes at any given depth) in a sequence of nodes provided as input.
If more then one answer is possible, return the first node according to the order of the input sequence.
Example usage :
most-nodes( ( <a><b/></a>, <a/>, <b/>) )
The function invocation in the example above returns :
(<a><b/></a>)
declare function con:most-similar-edit-distance($s as xs:string*, $m as xs:string) as xs:string?
Returns the single most similar string, in terms of the edit distance metric towards an input string, in a sequence of strings provided as input. If more than one string has a maximum similarity (a minimum value for the edit distance metric), the function return the first string according to the order of the input sequence.
Example usage :
most-similar-edit-distance( ( "aaabbbccc", "aaabbb", "eeefff" ), "aaab" )
The function invocation in the example above returns :
( "aaabbb" )
declare function con:most-tokens($s as xs:string*, $r as xs:string) as xs:string?
Returns the single longest string, in terms of the number of tokens, in a sequence of strings provided as input.
If more then one answer is possible, return the first string according to the order of the input sequence.
Example usage :
most-tokens( ( "a b c", "a b", "a"), " +" )
The function invocation in the example above returns :
("a b c")
declare function con:most-xpaths($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the single element from an input sequence of elements that matches the largest number of XPath expressions from a given set, producing a non-empty set of nodes.
If more then one answer is possible, return the first element according to the order of the input sequence.
Example usage :
most-xpaths( ( <a><b/></a>, <d><c/><b/></d>, <d/>) , (".//b", ".//c") )
The function invocation in the example above returns :
( <d><c/><b/></d> )
declare function con:shortest($s as xs:string*) as xs:string?
Returns the single shortest string, in terms of the number of characters, in a sequence of strings provided as input.
If more then one answer is possible, return the first string according to the order of the input sequence.
Example usage :
shortest( ( "a", "aa", "aaa") )
The function invocation in the example above returns :
("a")
declare function con:some-xpaths($s as element(*)*, $paths as xs:string*) as element(*)*
Returns the elements from a sequence of elements that, when matched to a given set of XPath expressions, produce a non-empty set of nodes for some of the cases.
Example usage :
some-xpaths( ( <a><b/></a>, <d><c/></d>, <d/>), (".//b", ".//c") )
The function invocation in the example above returns :
( <a><b/></a> , <d><c/></d> )
declare function con:superstring($s as xs:string*) as xs:string?
Returns the single string, from an input sequence of strings, that appears more frequently as part of the other strings in the sequence. If no such string exists, the function returns an empty sequence.
If more then one answer is possible, the function returns the first string according to the order of the input sequence.
Example usage :
super-string( ( "aaa bbb ccc", "aaa bbb", "aaa ddd", "eee fff" ) )
The function invocation in the example above returns :
( "aaa bbb" )
declare function con:validating-schema($s as element(*)*, $schema as element(*)) as element(*)*
Returns the nodes from an input sequence of nodes that validate against a given XML Schema.
Example usage :
validating-schema ( ( <a/> , <b/> ), <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:element name="a" /></xs:schema> )
The function invocation in the example above returns :
( <a/> )