Skip to content

Commit

Permalink
Allow document-node(NameTestUnion)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhkay committed Nov 24, 2024
1 parent 7604122 commit 39b1453
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
7 changes: 3 additions & 4 deletions specifications/grammar-40/xpath-grammar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1403,11 +1403,9 @@ ErrorVal ::= "$" VarName
</g:production>

<g:production name="NameTestUnion" if="xpath40 xquery40">
<g:ref name="NameTest"/>
<g:zeroOrMore>
<g:string>|</g:string>
<g:oneOrMore separator="|">
<g:ref name="NameTest"/>
</g:zeroOrMore>
</g:oneOrMore>
</g:production>

<!-- ] end TryCatchExpr -->
Expand Down Expand Up @@ -2628,6 +2626,7 @@ ErrorVal ::= "$" VarName
<g:choice name="DocumentTestBodyChoice">
<g:ref name="ElementTest"/>
<g:ref name="SchemaElementTest"/>
<g:ref name="NameTestUnion"/>
</g:choice>
</g:optional>
<g:string>)</g:string>
Expand Down
6 changes: 3 additions & 3 deletions specifications/xpath-functions-40/src/function-catalog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18876,7 +18876,7 @@ return $lines[not(position() = last() and . = '')]

<fos:function name="parse-xml" prefix="fn">
<fos:signatures>
<fos:proto name="parse-xml" return-type="document-node(element(*))?">
<fos:proto name="parse-xml" return-type="document-node(*)?">
<fos:arg name="value" type="xs:string?" example="'&lt;a/&gt;'"/>
<fos:arg name="options" type="map(*)?" default="{}"/>
</fos:proto>
Expand Down Expand Up @@ -19672,7 +19672,7 @@ serialize(
</fos:function>
<fos:function name="parse-html" prefix="fn">
<fos:signatures>
<fos:proto name="parse-html" return-type="document-node(element(*:html))?">
<fos:proto name="parse-html" return-type="document-node(*:html)?">
<fos:arg name="html" type="(xs:string | xs:hexBinary | xs:base64Binary)?"/>
<fos:arg name="options" type="map(*)?"
default="{
Expand Down Expand Up @@ -24708,7 +24708,7 @@ return $M(collation-key("a", $C))</eg></fos:expression>

<fos:function name="json-to-xml" prefix="fn">
<fos:signatures>
<fos:proto name="json-to-xml" return-type="document-node()?">
<fos:proto name="json-to-xml" return-type="document-node(fn:*)?">
<fos:arg name="value" type="xs:string?" example="'[22, 23]'"/>
<fos:arg name="options" type="map(*)?" usage="inspection" default="{}"/>
</fos:proto>
Expand Down
43 changes: 31 additions & 12 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4453,6 +4453,11 @@ declare variable $orange-fruit as my:fruit := "orange";
The <code>NodeTest</code> in an <code>AxisStep</code> now allows alternatives:
<code>ancestor::(section|appendix)</code>
</change>
<change issue="1593" date="2024-11-24">
The syntax <code>document-node(<var>N</var>)</code>, where <var>N</var> is a <code>NameTestUnion</code>,
is introduced as an abbreviation for <code>document-node(element(<var>N</var>))</code>. For example,
<code>document-node(*)</code> matches any well-formed XML document (as distinct from a document fragment).
</change>
</changes>

<p diff="add" at="A">Some of the constructs described in this section include a <nt def="TypeName">TypeName</nt>. This appears
Expand Down Expand Up @@ -4552,13 +4557,13 @@ declare variable $orange-fruit as my:fruit := "orange";
<p>
<code>document-node(</code>
<emph>E</emph>
<code>)</code>
matches any document node that contains exactly one element node, optionally accompanied by one or more comment and processing instruction nodes, if
<emph>E</emph> is an <nt
<code>)</code>, where <var>E</var> is an <nt
def="ElementTest">ElementTest</nt> or <nt def="SchemaElementTest"
>SchemaElementTest</nt> that matches the element node (see
<specref
ref="id-element-test"/> and <specref ref="id-schema-element-test"/>).</p>
>SchemaElementTest</nt> (see <specref
ref="id-element-test"/> and <specref ref="id-schema-element-test"/>)
matches any document node whose children comprise (in any order) zero or more
comment and processing instruction nodes, zero text nodes, and exactly one element node,
which itself must match <var>E</var>.</p>
<p>Example:
<code role="parse-test"
>document-node(element(book))</code> matches a document node
Expand All @@ -4567,6 +4572,15 @@ declare variable $orange-fruit as my:fruit := "orange";
<code
role="parse-test">element(book)</code>.</p>
</item>

<item><p>The construct <code>document-node(<var>NTU</var>)</code>, where
<var>NTU</var> is a <nt def="NameTestUnion">NameTestUnion</nt>, is
an abbreviation for <code>document-node(element(<var>NTU</var>))</code>.
For example, <code>document-node(*)</code> is an abbreviation for
<code>document-node(element(*))</code>, which matches any document node
corresponding to a well-formed XML document, that is, one that has
one element child, zero or more comment and processing-instruction children,
and no text node children.</p></item>


<item>
Expand Down Expand Up @@ -6304,23 +6318,26 @@ declare record Particle (
</example>
</item>
<item>
<p><var>A</var> is <code>document-node(<var>E</var>)</code> for any <nt def="ElementTest">ElementTest</nt> <var>E</var>,
<p><var>A</var> is <code>document-node(<var>E</var>)</code> for any <var>E</var>,
and <var>B</var> is <code>document-node()</code>.</p>
<example>
<head>Example:</head>
<head>Examples:</head>
<p><code>document-node(element(chap)) ⊆ document-node()</code></p>
<p><code>document-node(*) ⊆ document-node()</code></p>
</example>
</item>
<item>
<p>All the following are true:</p>
<p>All the following are true, after expanding <code>document-node(<var>NameTestUnion</var>)</code>
to <code>document-node(element(<var>NameTestUnion)</var>)</code>:</p>
<olist>
<item><p><var>A</var> is <code>document-node(<var>A/e</var>)</code></p></item>
<item><p><var>B</var> is <code>document-node(<var>B/e</var>)</code></p></item>
<item><p><code><var>A/e</var> ⊆ <var>B/e</var></code></p></item>
</olist>
<example>
<head>Example:</head>
<head>Examples:</head>
<p><code>document-node(element(title)) ⊆ document-node(element(*))</code>.</p>
<p><code>document-node(title) ⊆ document-node(*)</code>.</p>
</example>
</item>
</olist>
Expand Down Expand Up @@ -11941,14 +11958,16 @@ return if (every $r in $R satisfies $r instance of node())
<p>
<code role="parse-test"
>document-node(element(book))</code>
matches any document node whose content consists of
matches any document node whose children consist of
a single element node that satisfies the <termref
def="dt-kind-test">kind test</termref>
<code role="parse-test"
>element(book)</code>, interleaved with zero or more
comments and processing
instructions.</p>
instructions, and no text nodes.</p>
</item>
<item><p><code>document-node(book)</code> is an abbreviation
for <code>document-node(element(book))</code>.</p></item>

</ulist>
</div4>
Expand Down

0 comments on commit 39b1453

Please sign in to comment.