## [saxon] Range expression in predicate

 [saxon] Range expression in predicate From: Roger Kovack - 2004-02-25 00:53:56 ```\$this/saxon:evaluate('/doc[1]/doc[10]') returns one element as expected \$this/saxon:evaluate('/doc[1]/doc[9]') returns one element as expected \$this/saxon:evaluate('/doc[1]/doc[9 to 10]') returns all the elements in this axis \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') returns all the elements in this axis Is this expected behavior? I would have thought \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') would have returned just 2 elements. Would the stylesheet help here? Roger Kovack ```

 [saxon] Range expression in predicate From: Roger Kovack - 2004-02-25 00:53:56 ```\$this/saxon:evaluate('/doc[1]/doc[10]') returns one element as expected \$this/saxon:evaluate('/doc[1]/doc[9]') returns one element as expected \$this/saxon:evaluate('/doc[1]/doc[9 to 10]') returns all the elements in this axis \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') returns all the elements in this axis Is this expected behavior? I would have thought \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') would have returned just 2 elements. Would the stylesheet help here? Roger Kovack ```
 RE: [saxon] Range expression in predicate From: Michael Kay - 2004-02-25 09:11:59 ```A predicate is treated as a numeric predicate (with an implicit "position() = P") only if it consists of a single number. In all other cases, the effective Boolean value is used. The effective Boolean value of any sequence containing 2 or more items is true. You need to write SEQ[position() = 9 to 10] There was a reason that XPath 2.0 was designed like this. Although the numeric interpretation works well for a constant range like this, it doesn't extend well for arbitrary sequences, especially expressions that are dependent on the context like SEQ[1 to position()], or heterogeneous sequences like SEQ[1 to 1000, true()]. Michael Kay # -----Original Message----- # From: saxon-help-admin@... [mailto:saxon-help- # admin@...] On Behalf Of Roger Kovack # Sent: 25 February 2004 00:43 # To: saxon-help@... # Subject: [saxon] Range expression in predicate # # \$this/saxon:evaluate('/doc[1]/doc[10]') returns one element as # expected # \$this/saxon:evaluate('/doc[1]/doc[9]') returns one element as expected # \$this/saxon:evaluate('/doc[1]/doc[9 to 10]') returns all the # elements in this axis # \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') returns all the # elements in this axis # # Is this expected behavior? I would have thought # \$this/saxon:evaluate('/doc[1]/doc[1 to 2]') # would have returned just 2 elements. # # Would the stylesheet help here? # # Roger Kovack # # # # ------------------------------------------------------- # SF.Net is sponsored by: Speed Start Your Linux Apps Now. # Build and deploy apps & Web services for Linux with # a free DVD software kit from IBM. Click Now! # http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click # _______________________________________________ # saxon-help mailing list # saxon-help@... # https://lists.sourceforge.net/lists/listinfo/saxon-help ```