Skip to content

Commit

Permalink
Fix issue 1678
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Jan 5, 2025
1 parent 4eaeba1 commit b88cfca
Showing 1 changed file with 66 additions and 57 deletions.
123 changes: 66 additions & 57 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3848,7 +3848,7 @@ the schema type named <code>us:address</code>.</p>
<code>xs:decimal</code> value is expected, the value retains its type
as <code>xs:integer</code>.</p>

<p>The definition of <termref def="dt-sequencetype-matching"
<!-- <p>The definition of <termref def="dt-sequencetype-matching"
>SequenceType matching</termref> relies
on a pseudo-function named <code>derives-from(</code>
<emph>AT</emph>,
Expand Down Expand Up @@ -3910,7 +3910,7 @@ the schema type named <code>us:address</code>.</p>
</p>
</item>

</ulist>
</ulist>-->

<p>The rules for <termref def="dt-sequencetype-matching"
>SequenceType
Expand Down Expand Up @@ -3970,6 +3970,36 @@ the schema type named <code>us:address</code>.</p>
value that is an empty sequence.</p>

</div3>
<div3 id="id-schema-type-derivation">
<head>Schema Type Relationships</head>

<p>Some <termref def="dt-item-type">item types</termref> are defined in terms
of <termref def="dt-schema-type">schema types</termref>, and the matching
rules for such item types depend on the rules defining relationships between
schema types in the XSD specification.</p>

<p><termdef id="dt-derives-from" term="derives from" open="true">A
<termref def="dt-schema-type"/> <var>S1</var> is said to <term>derive from</term>
<termref def="dt-schema-type"/> <var>S2</var> if any of the following
conditions is true:</termdef></p>

<ulist>
<item><p><var>S1</var> is the same type as <var>S2</var>.</p></item>
<item><p><var>S2</var> is the base type of <var>S1</var>.</p></item>
<item><p><var>S2</var> is a <termref def="dt-pure-union-type"/>
of which <var>S1</var> is a member type.</p></item>
<item><p>There is a <termref def="dt-schema-type"/> <var>M</var> such that
<var>S1</var> <termref def="dt-derives-from"/> <var>M</var>
and <var>M</var> <termref def="dt-derives-from"/> <var>S2</var>.</p></item>
</ulist>
<p role="closetermdef"/>

<note><p>The XML Schema specification does not completely specify the circumstances
under which <var>S1</var> and <var>S2</var> are considered to be the same
type. For example, if both are anonymous union types with the same member types,
but defined in different places in the schema, then schema processors have
discretion whether to treat them as the same type.</p></note>
</div3>
</div2>
<div2 id="id-matching-item">
<head>Item Types</head>
Expand Down Expand Up @@ -4137,7 +4167,7 @@ the schema type named <code>us:address</code>.</p>
<p diff="add" at="2023-02-20">An atomic item <var>A</var> matches the
<termref def="dt-generalized-atomic-type"/> <var>GAT</var>
if the <termref def="dt-type-annotation">type annotation</termref> of <var>A</var>
(call it <var>T</var>) satisfies the condition <code>derives-from(T, GAT)</code>.</p>
<termref def="dt-derives-from"/> <var>GAT</var>.</p>

<p>Example: The <nt def="ItemType">ItemType</nt>
<code>xs:decimal</code> matches any value of type
Expand Down Expand Up @@ -4645,10 +4675,9 @@ declare variable $orange-fruit as my:fruit := "orange";
<item><p><var>NT</var> is an <code>EQName</code> equal to <var>N</var>.</p></item>
</olist>
</item>
<item><p>If <var>ET</var> includes a <nt def="TypeName">TypeName</nt>,
<item><p>If <var>ET</var> includes a <nt def="TypeName">TypeName</nt> <var>T</var>,
then the <termref def="dt-type-annotation"/> of the element node <var>E</var>
is either the schema type identified by that type name, or a type derived from that
type by restriction.</p></item>
<termref def="dt-derives-from"/> <var>T</var>.</p></item>
<item><p>If <var>E</var> has the <code>nilled</code> property, then <var>ET</var>
either includes no <nt def="TypeName">TypeName</nt>,
or includes a <nt def="TypeName">TypeName</nt> followed by the symbol <code>?</code>.</p></item>
Expand Down Expand Up @@ -4814,11 +4843,11 @@ matches any nilled or non-nilled element node whose type annotation is
<p>Either:</p>
<olist>
<item>
<p>The name <emph>N</emph> of the candidate node matches the specified <nt
<p>The name <var>N</var> of the candidate node matches the specified <nt
def="ElementName">ElementName</nt>, or</p>
</item>
<item>
<p>The name <emph>N</emph> of the candidate node matches the name of an element declaration that is a member of the actual substitution group headed by the declaration of element <nt
<p>The name <var>N</var> of the candidate node matches the name of an element declaration that is a member of the actual substitution group headed by the declaration of element <nt
def="ElementName">ElementName</nt>.</p>
</item>

Expand All @@ -4827,21 +4856,31 @@ matches any nilled or non-nilled element node whose type annotation is
<note>
<p>The term “actual substitution group” is defined in <bibref
ref="XMLSchema11"
/>. The actual substitution group of an element declaration <emph>H</emph> includes those element declarations <emph>P</emph> that are declared to have <emph>H</emph> as their direct or indirect substitution group head, provided that <emph>P</emph> is not declared as abstract, and that <emph>P</emph> is validly substitutable for <emph>H</emph>, which means that there must be no blocking constraints that prevent substitution.</p>
/>. The actual substitution group of an element declaration
<var>H</var> includes those element declarations
<var>P</var> that are declared to have <var>H</var> as their
direct or indirect substitution group head, provided that
<var>P</var> is not declared as abstract, and that <var>P</var>
is validly substitutable for <var>H</var>, which means that
there must be no blocking constraints that prevent substitution.</p>
</note>
</item>

<item>
<p>The schema element declaration named <emph>N</emph> is not abstract.</p>
<p>The schema element declaration named <var>N</var> is not abstract.</p>
</item>

<item>
<p>
<code>derives-from( AT, ET )</code> is true, where <emph>AT</emph> is the type annotation of the candidate node and <emph>ET</emph> is the schema type declared in the schema element declaration named <emph>N</emph>.</p>
<p><var>AT</var> <termref def="dt-derives-from"/> <var>ET</var>,
where <var>AT</var> is the type annotation of the candidate node
and <var>ET</var> is the schema type declared in the schema element
declaration named <var>N</var>.</p>
</item>

<item>
<p>If the schema element declaration named <emph>N</emph> is not nillable, then the nilled property of the candidate node is <code>false</code>.</p>
<p>If the schema element declaration named <var>N</var>
is not nillable, then the <code>nilled</code> property of the candidate node
is <code>false</code>.</p>
</item>

</olist>
Expand All @@ -4868,7 +4907,7 @@ in the following two situations:
considerations apply:</p>

<ulist>
<item><p>In applying the test <code>derives-from( AT, ET )</code>,
<item><p>In applying the test <code><var>AT</var> derives-from <var>ET</var></code>,
note that <var>AT</var> will necessarily be present in <var>X</var>,
but not necessarily in <var>Y</var>. However, <var>ET</var> will
necessarily be present in both; and because the two schemas
Expand Down Expand Up @@ -4954,10 +4993,9 @@ in the following two situations:
<item><p><var>NT</var> is an <code>EQName</code> equal to <var>N</var>.</p></item>
</olist>
</item>
<item><p>If <var>AT</var> includes a <nt def="TypeName">TypeName</nt>,
<item><p>If <var>AT</var> includes a <nt def="TypeName">TypeName</nt> <var>T</var>,
then the <termref def="dt-type-annotation"/> of the attribute node <var>A</var>
is either the schema type identified by that type name, or a type derived from that
type by restriction.</p></item>
<termref def="dt-derives-from"/> <var>T</var>.</p></item>
</olist>
<p>Here are some examples of <nt def="AttributeTest"
>AttributeTests</nt>:
Expand Down Expand Up @@ -5099,10 +5137,9 @@ name.</p>
</item>

<item>
<p>
<code>derives-from(</code>
<emph>AT, ET</emph>
<code>)</code> is <code>true</code>, where <emph>AT</emph> is the type annotation of the candidate node and <emph>ET</emph> is the schema type declared for attribute <nt
<p><var>AT</var> <termref def="dt-derives-from"/> <var>ET</var>,
where <var>AT</var> is the type annotation of the candidate node and
<var>ET</var> is the schema type declared for attribute <nt
def="AttributeName">AttributeName</nt> in the <termref def="dt-is-attrs"
>in-scope attribute declarations</termref>.</p>
</item>
Expand Down Expand Up @@ -6206,8 +6243,7 @@ declare record Particle (
<olist>
<item>
<p><var>A</var> and <var>B</var> are <termref def="dt-generalized-atomic-type">generalized atomic types</termref>,
and <code>derives-from(<var>A</var>, <var>B</var>)</code> returns <code>true</code>.</p>
<p>The <code>derives-from</code> relationship is defined in <specref ref="id-sequencetype-matching"/>.</p>
and <var>A</var> <termref def="dt-derives-from"/> <var>B</var>.</p>
<example diff="add" at="B">
<head>Examples:</head>
<ulist>
Expand Down Expand Up @@ -6357,10 +6393,10 @@ declare record Particle (
<item>
<p>All the following are true:</p>
<olist>
<item><p><var>A</var> is <code>element(<var>A/n</var>, <var>A/t</var>)</code></p></item>
<item><p><var>B</var> is <code>element(<var>B/n</var>, <var>B/t</var>)</code></p></item>
<item><p><var>A/n</var> <termref def="dt-wildcard-matches"/> <var>B/n</var></p></item>
<item><p><code>derives-from(<var>A/t</var>, <var>B/t</var>)</code>.</p></item>
<item><p><var>A</var> is <code>element(<var>A/n</var>, <var>A/t</var>)</code>.</p></item>
<item><p><var>B</var> is <code>element(<var>B/n</var>, <var>B/t</var>)</code>.</p></item>
<item><p><var>A/n</var> <termref def="dt-wildcard-matches"/> <var>B/n</var>.</p></item>
<item><p><var>A/t</var> <termref def="dt-derives-from"/> <var>B/t</var>.</p></item>
</olist>
<example>
<head>Examples:</head>
Expand All @@ -6381,7 +6417,7 @@ declare record Particle (
<code>element(<var>A/n</var>, <var>A/t</var>?)</code></p></item>
<item><p><var>B</var> is <code>element(<var>B/n</var>, <var>B/t</var>?)</code></p></item>
<item><p><var>A/n</var> <termref def="dt-wildcard-matches"/> <var>B/n</var></p></item>
<item><p><code>derives-from(<var>A/t</var>, <var>B/t</var>)</code>.</p></item>
<item><p><var>A/t</var> <termref def="dt-derives-from"/> <var>B/t</var>.</p></item>
</olist>
<example>
<head>Examples:</head>
Expand All @@ -6394,25 +6430,7 @@ declare record Particle (
</ulist>
</example>
</item>
<!--<item>
<p>All the following are true:</p>
<olist>
<item><p><code>Ai</code> is either <code>element(*, At)</code> or <code>element(N, At)</code> for any name N</p></item>
<item><p><code>Bi</code> is <code>element(*, Bt)</code></p></item>
<item><p><code>derives-from(At, Bt)</code>.</p></item>
</olist>

</item> -->

<!--<item>
<p>All the following are true:</p>
<olist>
<item><p><code>A</code> is either <code>element(*, At)</code>, <code>element(*, At?)</code>,
<code>element(N, At)</code>, or <code>element(N, At?)</code> for any name N</p></item>
<item><p><code>B</code> is <code>element(*, Bt?)</code></p></item>
<item><p><code>derives-from(At, Bt)</code>.</p></item>
</olist>
</item>-->

<item>
<p>All the following are true:</p>
Expand Down Expand Up @@ -6490,8 +6508,7 @@ declare record Particle (
<item><p><var>A</var> is <code>attribute(<var>A/n</var>, <var>A/t</var>)</code></p></item>
<item><p><var>B</var> is <code>attribute(<var>B/n</var>, <var>B/t</var>)</code></p></item>
<item><p><var>A/n</var> <termref def="dt-wildcard-matches"/> <var>B/n</var></p></item>

<item><p><code>derives-from(<var>A/t</var>, <var>B/t</var>)</code>.</p></item>
<item><p><var>A/t</var> <termref def="dt-derives-from"/> <var>B/t</var>.</p></item>
</olist>

<example>
Expand All @@ -6507,15 +6524,7 @@ declare record Particle (
</example>

</item>
<!--<item>
<p>All the following are true:</p>
<olist>
<item><p><code>A</code> is either <code>attribute(*, At)</code>, or <code>attribute(N, At)</code> for any name N</p></item>
<item><p><code>B</code> is <code>attribute(*, Bt)</code></p></item>
<item><p><code>derives-from(At, Bt)</code>.</p></item>
</olist>
</item>
-->

<item>
<p>All the following are true:</p>
<olist>
Expand Down

0 comments on commit b88cfca

Please sign in to comment.