Skip to content

Commit

Permalink
Merge pull request #798 from ChristianGruen/479
Browse files Browse the repository at this point in the history
479: fn:deep-equal: Input order
  • Loading branch information
ndw authored Dec 12, 2023
2 parents 4aa97e1 + ff34626 commit fbb5cda
Showing 1 changed file with 71 additions and 31 deletions.
102 changes: 71 additions & 31 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13565,14 +13565,21 @@ return contains-sequence(
<p>If the two sequences are both empty, the function returns <code>true</code>.</p>
<p>If the two sequences are of different lengths, the function returns
<code>false</code>.</p>
<p>If the two sequences are of the same length, the function returns <code>true</code> if
<p>If the two sequences are of the same length, the comparison is controlled by the
<code>unordered</code> option:</p>
<ulist>
<item><p>If the option is <code>false</code>, the function returns <code>true</code> if
and only if every item in the sequence <code>$input1</code> is deep-equal to the
item at the same position in the sequence <code>$input2</code>. The rules for
item at the same position in the sequence <code>$input2</code>.
</p></item>
<item><p>Otherwise, the function returns <code>true</code> if for every item in
<code>$input1</code> there is a deep-equal item in <code>$input2</code> that
has not been matched to another item.</p></item>
</ulist>
<p>The rules for
deciding whether two items are deep-equal appear below.</p>


<p>The entries that may appear in the <code>$options</code> map are as follows. The detailed rules
for the interpretation of each option appear later.</p>
<p>The entries that may appear in the <code>$options</code> map are as follows. The detailed rules
for the interpretation of each option appear later.</p>

<fos:options>
<fos:option key="base-uri">
Expand Down Expand Up @@ -13668,6 +13675,13 @@ return contains-sequence(
<fos:type>xs:boolean</fos:type>
<fos:default>true</fos:default>
</fos:option>
<fos:option key="unorderd">
<fos:meaning>Controls whether the top-level order of the items of the input sequences
is considered.
</fos:meaning>
<fos:type>xs:boolean</fos:type>
<fos:default>false</fos:default>
</fos:option>
<fos:option key="unordered-elements">
<fos:meaning>A list of QNames of elements considered to be unordered: that is, their child
elements may appear in any order.
Expand Down Expand Up @@ -14144,66 +14158,94 @@ declare function equal-strings(
</fos:example>
<fos:example>
<fos:test>
<fos:expression>deep-equal(map{1:'a', 2:'b'}, map{2:'b', 1:'a'})</fos:expression>
<fos:expression>deep-equal([1, 2, 3], [1, 2, 3])</fos:expression>
<fos:result>true()</fos:result>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression>deep-equal([1, 2, 3], [1, 2, 3])</fos:expression>
<fos:expression>deep-equal((1, 2, 3), [1, 2, 3])</fos:expression>
<fos:result>false()</fos:result>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg>deep-equal(
map { 1: 'a', 2: 'b' },
map { 2: 'b', 1: 'a' }
)</eg></fos:expression>
<fos:result>true()</fos:result>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression>deep-equal((1, 2, 3), [1, 2, 3])</fos:expression>
<fos:expression><eg>deep-equal(
(1, 2, 3, 4),
(1, 4, 3, 2),
map { 'unordered': true() }
)</eg></fos:expression>
<fos:result>true()</fos:result>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg>deep-equal(
(1, 1, 2, 3),
(1, 2, 3, 3),
map { 'unordered': true() }
)</eg></fos:expression>
<fos:result>false()</fos:result>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>"))]]></eg></fos:expression>
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>")
)]]></eg></fos:expression>
<fos:result>true()</fos:result>
<fos:postamble>By default, namespace prefixes are ignored</fos:postamble>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>"),
options := map{'namespace-prefixes':true()})]]></eg></fos:expression>
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>"),
options := map { 'namespace-prefixes': true() }
)]]></eg></fos:expression>
<fos:result>false()</fos:result>
<fos:postamble>False because the namespace prefixes differ</fos:postamble>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>"),
options := map{'in-scope-namespaces':true()})]]></eg></fos:expression>
parse-xml("<a xmlns='AA'/>"),
parse-xml("<p:a xmlns:p='AA'/>"),
options := map { 'in-scope-namespaces': true() }
)]]></eg></fos:expression>
<fos:result>false()</fos:result>
<fos:postamble>False because the in-scope namespace bindings differ</fos:postamble>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml("<a><b/><c/></a>"),
parse-xml("<a><c/><b/></a>"))]]></eg></fos:expression>
parse-xml("<a><b/><c/></a>"),
parse-xml("<a><c/><b/></a>")
)]]></eg></fos:expression>
<fos:result>false()</fos:result>
<fos:postamble>By default, order of elements is significant</fos:postamble>
</fos:test>
</fos:example>
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml("<a><b/><c/></a>"),
parse-xml("<a><c/><b/></a>"),
options := map{'unordered-elements': parse-QName('a')})]]></eg></fos:expression>
parse-xml("<a><b/><c/></a>"),
parse-xml("<a><c/><b/></a>"),
options := map {'unordered-elements': xs:QName('a') }
)]]></eg></fos:expression>
<fos:result>true()</fos:result>
<fos:postamble>The <code>unordered-elements</code> option means that the ordering of the children
of <code>a</code> is ignored.</fos:postamble>
Expand All @@ -14212,10 +14254,9 @@ declare function equal-strings(
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml(
"<para style='bold'><span>x</span></para>"),
parse-xml(
"<para style=' bold'> <span>x</span></para>"))]]></eg></fos:expression>
parse-xml("<para style='bold'><span>x</span></para>"),
parse-xml("<para style=' bold'> <span>x</span></para>")
)]]></eg></fos:expression>
<fos:result>false()</fos:result>
<fos:postamble>By default, both the leading whitespace in the <code>style</code> attribute
and the whitespace text node preceding the <code>span</code> element are significant.</fos:postamble>
Expand All @@ -14224,11 +14265,10 @@ declare function equal-strings(
<fos:example>
<fos:test>
<fos:expression><eg><![CDATA[deep-equal(
parse-xml(
"<para style='bold'><span>x</span></para>"),
parse-xml(
"<para style=' bold'> <span>x</span></para>"),
options := map{'whitespace': 'normalize'})]]></eg></fos:expression>
parse-xml("<para style='bold'><span>x</span></para>"),
parse-xml("<para style=' bold'> <span>x</span></para>"),
options := map { 'whitespace': 'normalize' }
)]]></eg></fos:expression>
<fos:result>false()</fos:result>
<fos:postamble>The <code>whitespace</code> option causes both the leading space
in the attribute value and the whitespace preceding the
Expand Down

0 comments on commit fbb5cda

Please sign in to comment.