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 29314 - [FO31] Code example in http://www.w3.org/TR/xpath-functions-31/#func-random-number-generator does not work
Summary: [FO31] Code example in http://www.w3.org/TR/xpath-functions-31/#func-random-n...
Status: CLOSED FIXED
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: Functions and Operators 3.1 (show other bugs)
Version: Candidate Recommendation
Hardware: PC Windows NT
: P2 editorial
Target Milestone: ---
Assignee: Michael Kay
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-29 18:30 UTC by Martin Honnen
Modified: 2016-03-22 09:55 UTC (History)
1 user (show)

See Also:


Attachments

Description Martin Honnen 2015-11-29 18:30:41 UTC
I have tried the code example given in http://www.w3.org/TR/xpath-functions-31/#func-random-number-generator, it has the code 

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};
declare %private function r:random-sequence($length as xs:integer, $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next())
};


The is a closing `)` missing in the `else` clause, should be

declare %public function r:random-sequence($length as xs:integer) as xs:double* {
  r:random-sequence($length, fn:random-number-generator())
};
declare %private function r:random-sequence($length as xs:integer, $G as map(xs:string, item())) {
  if ($length eq 0)
  then ()
  else ($G?number, r:random-sequence($length - 1, $G?next()))
};
Comment 1 Michael Kay 2016-01-19 14:43:52 UTC
Thank you, this has now been fixed.