This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 6737 - example error
Summary: example error
Status: RESOLVED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 1.0 (show other bugs)
Version: Recommendation
Hardware: PC Windows XP
: P2 trivial
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL: http://www.w3.org/TR/xquery/
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-03-25 12:43 UTC by Radim
Modified: 2009-08-25 11:52 UTC (History)
0 users

See Also:


Attachments

Description Radim 2009-03-25 12:43:15 UTC
I guess the example XQuery at the end:
for $pn in fn:distinct-values(
      fn:doc("catalog.xml")/items/item/partno)
let $i := fn:doc("catalog.xml")/items/item[partno = $pn]
where fn:count($i) >= 3
order by $pn
return 
   <well-supplied-item>
      <partno> {$p} </partno>
      <avgprice> {fn:avg($i/price)} </avgprice>
   </well-supplied-item>



should be:
for $pn in fn:distinct-values(
      fn:doc("catalog.xml")/items/item/partno)
let $i := fn:doc("catalog.xml")/items/item[partno = $pn]
where fn:count($i) >= 3
order by $pn
return 
   <well-supplied-item>
      <partno> {$pn} </partno>
      <avgprice> {fn:avg($i/price)} </avgprice>
   </well-supplied-item>
Comment 1 Jonathan Robie 2009-03-25 13:57:11 UTC
You're right, the example refers to the variable $p, which is not bound:

<partno> {$p} </partno>

You have corrected this to use $pn:

<partno> {$pn} </partno>

(I'm saying this to make it faster for others to spot!)