Skip to content
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

52 Allow record(*) #728

Merged
merged 1 commit into from
Oct 10, 2023
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
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