Skip to content

Commit

Permalink
Define named record for key-value-pair
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Nov 24, 2024
1 parent 35f6fd1 commit 0a004ee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
19 changes: 16 additions & 3 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@
<fos:variable id="v-item3" name="item3" select="$po/line-item[3]"/>
</fos:global-variables>

<fos:record-type id="key-value-pair" extensible="true">
<fos:field name="key" type="xs:anyAtomicType" required="true">
<fos:meaning>
<p>A key suitable for use in a map entry.</p>
</fos:meaning>
</fos:field>
<fos:field name="value" type="item()*" required="true">
<fos:meaning>
<p>The value corresponding to the key.</p>
</fos:meaning>
</fos:field>
</fos:record-type>

<fos:record-type id="uri-structure-record" extensible="true">
<fos:field name="uri" type="xs:string?" required="false">
<fos:meaning>
Expand Down Expand Up @@ -22885,7 +22898,7 @@ return fold-left($maps, {},
<fos:signatures>
<fos:proto name="of-pairs" return-type="map(*)">
<fos:arg name="input"
type="record(key as xs:anyAtomicType, value as item()*)*"
type-ref="key-value-pair" type-ref-occurs="*"
usage="inspection"
example="{ 'key':'n','value':false() }, { 'key':'y','value':true() }"/>
<fos:arg name="combine" type="(fn(item()*, item()*) as item()*)?" usage="inspection" default="fn:op(',')"/>
Expand Down Expand Up @@ -23257,7 +23270,7 @@ return map:keys-where($birthdays, fn($name, $date) {

<fos:function name="pairs" prefix="map">
<fos:signatures>
<fos:proto name="pairs" return-type="record(key as xs:anyAtomicType, value as item()*)*">
<fos:proto name="pairs" return-type-ref="key-value-pair" return-type-ref-occurs="*">
<fos:arg name="map" type="map(*)" usage="inspection"/>
</fos:proto>
</fos:signatures>
Expand Down Expand Up @@ -23753,7 +23766,7 @@ map:merge(//book ! map:entry(isbn, .))]]></eg>

<fos:function name="pair" prefix="map">
<fos:signatures>
<fos:proto name="pair" return-type="record(key as xs:anyAtomicType, value as item()*)">
<fos:proto name="pair" return-type-ref="key-value-pair">
<fos:arg name="key" type="xs:anyAtomicType"/>
<fos:arg name="value" type="item()*" usage="navigation"/>
</fos:proto>
Expand Down
5 changes: 5 additions & 0 deletions specifications/xpath-functions-40/src/xpath-functions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7569,6 +7569,7 @@ return <table>
<item><p><termdef id="dt-key-value-pair-map" term="key-value pair map">A <term>key-value pair map</term> is a map containing two
entries, one (with the key <code>"key"</code>) containing the key part of a key value pair, the other (with the key <code>"value"</code>)
containing the value part of a key value pair.</termdef></p>
<p>The record type for a <termref def="dt-key-value-pair-map"/> is defined in <specref ref="key-value-pair"/>.</p>
<p>For example
the map <code>{ "x": 1, "y": 2 }</code> can be decomposed as
<code>({ "key": "x", "value": 1 }, { "key": "y", "value": 2 })</code></p>
Expand Down Expand Up @@ -7615,6 +7616,10 @@ return <table>
</tr>
</tbody>
</table>

<div3 id="key-value-pair">
<head><?record-description key-value-pair?></head>
</div3>

</div2>

Expand Down

0 comments on commit 0a004ee

Please sign in to comment.