Skip to content

Commit

Permalink
Allow record(*)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Sep 28, 2023
1 parent f61b05c commit 39a5d93
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
14 changes: 14 additions & 0 deletions specifications/grammar-40/xpath-grammar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2862,6 +2862,20 @@ ErrorVal ::= "$" VarName
</g:production>

<g:production name="RecordTest" if="xpath40 xquery40 xslt40-patterns">
<g:choice>
<g:ref name="AnyRecordTest"/>
<g:ref name="TypedRecordTest"/>
</g:choice>
</g:production>

<g:production name="AnyRecordTest" if="xpath40 xquery40 xslt40-patterns">
<g:string>record</g:string>
<g:string>(</g:string>
<g:string>*</g:string>
<g:string>)</g:string>
</g:production>

<g:production name="TypedRecordTest" if="xpath40 xquery40 xslt40-patterns">
<g:string>record</g:string>
<g:string>(</g:string>
<g:ref name="FieldDeclaration"/>
Expand Down
18 changes: 15 additions & 3 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5247,6 +5247,8 @@ name.</p>
<scrap headstyle="show">
<head/>
<prodrecap id="RecordTest" ref="RecordTest"/>
<prodrecap id="AnyRecordTest" ref="AnyRecordTest"/>
<prodrecap id="TypedRecordTest" ref="TypedRecordTest"/>
<prodrecap id="FieldDeclaration" ref="FieldDeclaration"/>
<prodrecap id="FieldName" ref="FieldName"/>
<prodrecap id="SelfReference" ref="SelfReference"/>
Expand All @@ -5269,6 +5271,11 @@ name.</p>
matches a map if it has an entry with key <code>"e"</code> whose value matches <code>element(Employee)</code>,
regardless what other entries the map might contain.</p>

<p>For generality, the syntax <code>record(*)</code> define an extensible record type that has no explicit
field declarations. The item type denoted by <code>record(*)</code> is equivalent to the item type
<code>map(*)</code>: that is, it allows any map.
</p>

<p>A record test can constrain only those entries whose keys are strings, but when the record
test is marked as extensible, then other entries may be present in the map with non-string keys.
Entries whose key is a string can be expressed using an (unquoted) NCName if the key conforms to
Expand Down Expand Up @@ -6352,15 +6359,20 @@ declare function flatten($tree as tree) as item()* {
<head>Record Tests</head>
<p>Given item types <var>A</var> and <var>B</var>, <var>A</var> <code>⊆</code> <var>B</var> is true if any of the following apply:</p>
<olist>
<item diff="add" at="issue52">
<p><var>A</var> is <code>map(*)</code> and <var>B</var> is <code>record(*)</code>.</p>
</item>
<item diff="add" at="A">
<p>All of the following are true:</p>
<olist>
<item><p><var>A</var> is a record test</p></item>
<item><p><var>B</var> is <code>map(*)</code></p></item>
<item><p><var>A</var> is a record test.</p></item>
<item><p><var>B</var> is <code>map(*)</code> or <code>record(*)</code>.</p></item>
</olist>
<example>
<head>Example:</head>
<head>Examples:</head>
<p><code>record(longitude, latitude)</code> ⊆ <code>map(*)</code></p>
<p><code>record(longitude, latitude, *)</code> ⊆ <code>record(*)</code></p>
<p><code>record(*)</code> ⊆ <code>map(*)</code></p>
</example>
</item>

Expand Down

0 comments on commit 39a5d93

Please sign in to comment.