Skip to content

Commit

Permalink
Add and use definition of sequence concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed May 8, 2024
1 parent 77b29d1 commit b7943eb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
17 changes: 11 additions & 6 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4161,7 +4161,8 @@ translate(value := '٢٠٢٣', replace := '٠١٢٣٤٥٦٧٨٩', with := '01234
the input sequence may be supplied using multiple arguments. In addition
the parameter is declared optional, so a call with no arguments is also permitted.</p>

<p>The result of the function is obtained by forming the sequence-concatenation of the supplied
<p>The result of the function is obtained by forming the
<xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref> of the supplied
argument values and applying the function <code>fn:string-join#0</code> to the result.</p>

<p>If XPath 1.0 compatibility mode is set to true in the static context of a
Expand Down Expand Up @@ -20831,7 +20832,9 @@ declare function transitive-closure (
<fos:value value="combine"
>
If duplicate keys are present, the result map includes an entry for the key whose
associated value is the sequence-concatenation of all the values associated with the key,
associated value is the
<xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref>
of all the values associated with the key,
retaining order based on the order of maps in the <code>$maps</code> argument.
The key value in the result map that corresponds to such a set of duplicates must
be the <termref
Expand Down Expand Up @@ -21043,7 +21046,7 @@ return fold-left($MAPS, {},
<fos:postamble>The value of the existing map is unchanged; the returned map
contains all the entries from <code>$week</code>, with one entry replaced by a
new entry. Both input maps contain an entry with the key <code>6</code>; the
entry that appears in the result is the sequence-concatenation of the entries
entry that appears in the result is the <xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref> of the entries
in the input maps, retaining order.</fos:postamble>
</fos:test>

Expand Down Expand Up @@ -22260,7 +22263,9 @@ fold-left($input, {}, fn($map, $item, $pos) {
<p>The default function for both <code>$keys</code> and <code>$value</code> is the identity function.
Although it is permitted to default both, this serves little purpose: usually at least one of these arguments
will be supplied.</p>
<p>The default action for combining entries with duplicate keys is to perform a sequence-concatenation of the corresponding values,
<p>The default action for combining entries with duplicate keys is to perform a
<xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref>
of the corresponding values,
equivalent to the <code>duplicates: combine</code> option on <code>map:merge</code>. Other potentially useful
functions for combining duplicates include:</p>
<ulist>
Expand Down Expand Up @@ -27255,10 +27260,10 @@ declare function flatten(
<fos:property>focus-independent</fos:property>
</fos:properties>
<fos:summary>
<p>Returns the sequence-concatenation of the members of an array.</p>
<p>Returns the sequence concatenation of the members of an array.</p>
</fos:summary>
<fos:rules>
<p>The function returns the sequence-concatenation of the members of
<p>The function returns the <xtermref spec="XP40" ref="dt-sequence-concatenation">sequence concatenation</xtermref> of the members of
<code>$array</code>, retaining order.</p>
<p>More formally, it returns the result of <code>array:members($array)?value</code>.</p>

Expand Down
21 changes: 15 additions & 6 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12237,6 +12237,13 @@ in the sequence <code>(1, 2, 3)</code>.</p>
new sequence is created by concatenating two or more input sequences, the new
sequence contains all the items of the input sequences and its length is the
sum of the lengths of the input sequences.</p>

<p><termdef id="dt-sequence-concatenation" term="sequence concatenation">The
<term>sequence concatenation</term> of a number of sequences <var>S/1</var>, <var>S/2</var>, ... <var>S/n</var>
is defined to be the sequence formed from the items of <var>S/1</var>, followed by the items
from <var>S/2</var>, and so on, retaining order.</termdef> The comma operator returns the sequence
concatenation of its two operands; repeated application (for example <code>$s1, $s2, $s3, $s4</code>)
delivers the sequence concatenation of multiple sequences.</p>
<note>
<p>In places where the grammar calls for <nt def="ExprSingle"
>ExprSingle</nt>, such as the arguments of a function call, any expression that contains a top-level comma operator must be enclosed in parentheses.</p>
Expand Down Expand Up @@ -16907,7 +16914,7 @@ processing with JSON processing.</p>

<p>Similarly, given <code>$M</code> as a map
<code>{ "X": ("a", "b"), "Y": ("c", "d"), "Z": ("e", "f") }</code>,
some example Lookup expressions are as follows. Note that because maps are unordered,
some example lookup expressions are as follows. Note that because maps are unordered,
the results are not necessarily in the order shown.</p>

<table width="100%">
Expand Down Expand Up @@ -17059,7 +17066,8 @@ processing with JSON processing.</p>

<p>If the modifier is <code>items</code> (explicitly or by default), the result of
<code>$V?items::KS</code> is the same as the result of
<code>$V?pairs::KS ! map:get(., "value")</code>.</p>
<code>$V?pairs::KS ! map:get(., "value")</code>; that is,
it is the <termref def="dt-sequence-concatenation"/> of the value parts.</p>

<p>If the modifier is <code>values</code>, the result of
<code>$V?values::KS</code> is the same as the result of
Expand Down Expand Up @@ -17319,7 +17327,8 @@ declare function recursive-content($item as item()) as record(key, value)* {
<ulist>
<item><p>If the modifier is <code>items</code> (explicitly or by default), the result of
<code>$V??items::KS</code> is the same as the result of
<code>$V??pairs::KS ! map:get(., "value")</code>.</p></item>
<code>$V??pairs::KS ! map:get(., "value")</code>; that is,
it is the <termref def="dt-sequence-concatenation"/> of the value parts.</p></item>

<item><p>If the modifier is <code>values</code>, the result of
<code>$V??values::KS</code> is the same as the result of
Expand Down Expand Up @@ -21621,8 +21630,8 @@ raised <errorref
>dynamic context</termref>. The sequences resulting from all the
evaluations of <code>E2</code> are combined as follows: Every evaluation
of <code>E2</code> returns a (possibly empty) sequence of items.
These sequences are concatenated and returned. <phrase
role="xquery" at="bug28862">If ordering mode is ordered, the</phrase>
The final result is the <termref def="dt-sequence-concatenation"/> of these sequences.
<phrase role="xquery" at="bug28862">If ordering mode is ordered, the</phrase>
<phrase role="xpath" at="bug28862"
>The</phrase> returned sequence preserves the orderings within and among the subsequences generated by the evaluations of <code>E2</code>
<phrase role="xpath">.</phrase>
Expand Down Expand Up @@ -21656,7 +21665,7 @@ raised <errorref
<tr>
<th>Additional processing</th>
<td>Duplicate elimination and document ordering</td>
<td>Simple sequence concatenation</td>
<td>Simple <termref def="dt-sequence-concatenation"/></td>
</tr>
</tbody>
</table>
Expand Down

0 comments on commit b7943eb

Please sign in to comment.