[F&O] CER-08 position-of

F&O 7.4.3

fn:substring takes positional parameters to figure out which substring to
select, but no functions are provided to determine the position of any
interesting piece of a string. Request the addition of such functions.

Options:
(a) One function that returns positions of all matches, similar to fn:index-of
    for sequence:

    fn:position-of( $source as xs:string, $pattern as xs:string ) as xs:integer*

    Example:
       let $suffix := substring( $url, position-of( $url, "/")[last()] )
       return substring( $suffix, position-of( $suffix, "#" )[1] )

(b) One function that gives first matching position, and one that gives
    the last matching position, similar to similar functions in various
    programming languages:

    fn:position-of( $source as xs:string, $pattern as xs:string ) as xs:integer
    fn:last-position-of( $source as xs:string, $pattern as xs:string ) as xs:integer

    Example: 
       let $suffix := substring( $url, last-position-of( $url, "/" ) )
       return substring( $suffix, position-of( $suffix, "#" ) )

Received on Tuesday, 17 February 2004 11:10:10 UTC