Skip to content

Commit

Permalink
Merge pull request qt4cg#903 from ChristianGruen/892
Browse files Browse the repository at this point in the history
892 XPDY0002: Misleading examples
  • Loading branch information
ndw authored Dec 19, 2023
2 parents 2db9af4 + fab88ca commit 5c88236
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions specifications/xquery-40/src/expressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8833,22 +8833,22 @@ return $f(5)]]></eg>
class="DY" code="0002"/>:</p>
<eg role="parse-test"><![CDATA[
let $vat := function() { @vat + @price }
return shop/article/$vat()]]></eg>
return doc('wares.xml')/shop/article/$vat()]]></eg>
<p>Instead, the context value can be used as an argument to the anonymous function:</p>
<eg role="parse-test"><![CDATA[
let $vat := function($art) { $art/@vat + $art/@price }
return shop/article/$vat(.)]]></eg>
return doc('wares.xml')/shop/article/$vat(.)]]></eg>
<p>Alternatively, the value can be referenced as a nonlocal variable binding:</p>
<eg role="parse-test"><![CDATA[
let $ctx := shop/article,
$vat := function() { for $a in $ctx return $a/@vat + $a/@price }
let $ctx := doc('wares.xml')/shop/article
let $vat := function() { for $a in $ctx return $a/@vat + $a/@price }
return $vat()
]]></eg>
<p>Finally, a <termref def="dt-focus-function"/> can be used.
This binds the value of the argument to the context value within the function body:</p>
<eg role="parse-test"><![CDATA[
let $vat := function { @vat + @price }
return $vat(shop/article)
return $vat(doc('wares.xml')/shop/article)
]]></eg>
</example>

Expand Down

0 comments on commit 5c88236

Please sign in to comment.