Giter Site home page Giter Site logo

Comments (3)

michaelhkay avatar michaelhkay commented on July 18, 2024

I'm trying to get to the bottom of this.

First problem I think is that otherwise binds more tightly than +, so it should be

let $start := index-where($input, $from)[1] otherwise (count($input) + 1)

I'm then getting a problem that in test subsequence-before-002, the expression mock:subsequence-where($in, to:=$pred) returns a different result from mock:subsequence-where($in, from:=true#0, to:=$pred). That must be a bug in Saxon's handling of default function parameters.

Got it: the code wasn't handling keyword arguments correctly in the case of functions imported from a library module. (There aren't many tests for that...)

from qtspecs.

michaelhkay avatar michaelhkay commented on July 18, 2024

Most of the subsequence-where tests are now passing using a mock implementation based on the equivalence expression in the spec, with parentheses added as described above.

The exceptions are tests subsequence-after-001, and subsequence-ending-where-101 to -108.

Those turned out to be errors in the way I converted the tests to call the mock version of the function. With that fixed, all the tests are now producing the expected results using the function:

declare function mock:subsequence-where (
  $input	as item()*,	
  $from	as (function(item(), xs:integer) as xs:boolean)?	:= true#0,
  $to	as (function(item(), xs:integer) as xs:boolean)?	:= false#0
) as item()*
{
   let $start := trace(index-where($input, $from)[1] 
              otherwise (count($input) + 1), '$start')
   let $end :=   trace(index-where($input, $to)[. ge $start][1] 
              otherwise (count($input) + 1), '$end')
   return slice($input, $start, $end)
};

As this exercise found a couple of Saxon bugs, I'm inclined to keep the tests for posterity...

from qtspecs.

michaelhkay avatar michaelhkay commented on July 18, 2024

Fixed by PR #1025

from qtspecs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.