Skip to content

1869 duplicate values #1873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 34 additions & 27 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14417,12 +14417,21 @@ return exists($break)
<item><p>The items that are returned appear in the order of their first
appearance within <code>$values</code>.</p></item>
</ulist>





</fos:rules>
<fos:equivalent style="xpath-expression">
filter($values,
fn($item, $pos) {
empty(
filter(
subsequence($values, 1, $pos - 1),
deep-equal(?, $item, $collation)
)
)
}
)
</fos:equivalent>
<fos:notes>
<p>If <code>$values</code> is the empty sequence, the function returns the empty sequence.</p>

Expand Down Expand Up @@ -14494,39 +14503,39 @@ return exists($break)
selected according to the rules in <specref ref="choosing-a-collation"/>.</p>
<p>From each resulting set of values that are considered equal, one value will be
returned if the set contains more than one value.</p>
<p>The ordering of the result is as follows:</p>

<p>Specifically, the function returns those items in <code>$values</code> that are
equal (under this definition) to exactly one item appearing earlier in the sequence</p>

<p>This means that the ordering of the result is as follows:</p>

<ulist>
<item><p>For any set of values that compare equal, the one that is
returned is the one that appears first in <code>$values</code>.</p></item>
<item><p>The items that are returned appear in the order of their first
returned is the one that appears second in <code>$values</code>.</p></item>
<item><p>The items that are returned appear in the order of their second
appearance within <code>$values</code>.</p></item>
</ulist>


</fos:rules>
<fos:equivalent style="xpath-expression">
filter($values,
fn($item, $pos) {
count(
filter(
subsequence($values, 1, $pos - 1),
deep-equal(?, $item, $collation)
)
) eq 1
}
)
</fos:equivalent>

<fos:notes>
<p>The effect of the function is equivalent to the following XSLT expression:</p>
<eg><![CDATA[
<xsl:for-each-group select="$values" group-by="." collation="{ $collation }">
<xsl:sequence select="current-group()[2]"/>
</xsl:for-each>
]]></eg>
<p>The following XQuery expression is equivalent if no collation is specified
(<code>group by</code> requires collation URIs to be static):</p>
<eg>
for $group in $values
group by $value := $group
where count($group) > 1
return $value
</eg>
</fos:notes>
<fos:examples>
<fos:example>
<fos:test>
<fos:expression>duplicate-values((1, 2, 3, 1.0, 1e0))</fos:expression>
<fos:result>1</fos:result>
<fos:result>1.0</fos:result>
</fos:test>
</fos:example>
<fos:example>
Expand All @@ -14538,7 +14547,7 @@ return $value
<fos:example>
<fos:test spec="XQuery">
<fos:expression><![CDATA[duplicate-values(('1', <x>1</x>, '2', 2))]]></fos:expression>
<fos:result>"1"</fos:result>
<fos:result>xs:untypedAtomic("1")</fos:result>
<fos:postamble>The string <code>"1"</code> and the untyped value of the
element node are considered equal, whereas the string <code>"2"</code>
and the integer are considered unequal.</fos:postamble>
Expand All @@ -14552,9 +14561,7 @@ return error((), 'Duplicate IDs found: ' || string-join($ids, ', '))</eg>
</fos:example>
</fos:examples>
<fos:changes>
<fos:change issue="123" PR="614"><p>New in 4.0</p></fos:change>
<fos:change issue="628" PR="987"><p>The order of results is now prescribed;
it was previously implementation-dependent.</p></fos:change>
<fos:change issue="123 628 1869" PR="614 987"><p>New in 4.0</p></fos:change>
</fos:changes>
</fos:function>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@
</xsl:template>

<xsl:template match="fos:equivalent">
<xsl:message terminate="yes">Non-matching fos:equivalent for {../@name}</xsl:message>
<xsl:message terminate="yes">On fos:equivalent for {../@name}, @style is missing or invalid</xsl:message>
</xsl:template>

<xsl:template match="fos:example">
Expand Down