…fixed – as well as some other issues. This is new in 6.1.7:
- ADD: new "ALTER DB" command to rename databases - ADD: XQuery "file" module (inspired by EXPath) - FIX: XQuery, recursive functions - FIX: XQuery, index access on elements without leaf nodes - FIX: GUI text editor, mouse and keyboard actions synchronized - FIX: GUI text editor, shortcuts for font size (ctrl +/-) - FIX: GUI text view, bold/plain text switch
Link to jar file:
http://basex.org/maven/org/basex/basex/6.1.7
Thanks, Christian
On Thu, Jun 17, 2010 at 10:08 PM, Christian Grün christian.gruen@gmail.com wrote:
Dave,
thanks for reporting. I could strip this down to the following example:
declare function local:f($a, $b) { if($a > $b) then local:f($b, $a) else $b - $a }; local:f(1, 0)
Fix is in progress, Christian
On Thu, Jun 17, 2010 at 9:35 PM, Dave Glick dglick@dracorp.com wrote:
I have discovered what appears to be a problem with recursive (or at least re-entering) XQuery functions. It doesn't happen all the time, in fact most of the simple test cases I could come up with seemed to work fine. However, the XQuery code below doesn't behave as expected or as it behaves in Stylus Studio. It is designed to report the number of weekdays between two dates. If the start date is less than the end date it works fine (you can check the answer in Excel using the NETWORKDAYS function). If the start date is greater, it should return the negative difference. Sure enough, the first number returned in the example case is 4 in both BaseX and Stylus Studio. However, the second number is -1 in BaseX when I was expecting -4.
Thanks for looking into this,
Dave
declare namespace functx = "http://www.functx.com"; declare function functx:day-of-week ( $date as xs:anyAtomicType? ) as xs:integer? { if (empty($date)) then () else xs:integer((xs:date($date) - xs:date('1901-01-06')) div xs:dayTimeDuration('P1D')) mod 7 }; declare function local:weekdays ($start as xs:anyAtomicType?, $end as xs:anyAtomicType?) as xs:integer? { if(empty($start) or empty($end)) then() else if($start > $end) then -local:weekdays($end, $start) else let $dayOfWeekStart := functx:day-of-week($start) let $dayOfWeekEnd := functx:day-of-week($end) let $adjDayOfWeekStart := if($dayOfWeekStart = 0) then 7 else $dayOfWeekStart let $adjDayOfWeekEnd := if($dayOfWeekEnd = 0) then 7 else $dayOfWeekEnd return if($adjDayOfWeekStart <= $adjDayOfWeekEnd) then xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + max(((min((($adjDayOfWeekEnd + 1), 6)) - $adjDayOfWeekStart), 0))) else xs:integer((xs:integer(days-from-duration(xs:date($end) - xs:date($start)) div 7) * 5) + min((($adjDayOfWeekEnd + 6) - min(($adjDayOfWeekStart, 6)), 5))) }; (local:weekdays('2010-06-14', '2010-06-17'), local:weekdays('2010-06-17', '2010-06-14')) _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk