Hi,
As far as I understand your description I would say that the following query does the job:
declare namespace xs=“XML Schema”
{-- determine sequence with distinct authors --}
let $q := for $a in distinct-values(input()/Authority/author) sort by (. ascending)
let $b := input()/Authority/author) [. = $a]
let $fb := $b[1]
{-- create the sequence entry with all the required attributes --}
return {($fb/@date,$fb/@ref,$fb/@type,$a)}
let $name := “Peter”
let $offset := 5
{-- determine position of “Peter” entry --}
{-- the xs:integer is required due to a bug in the Tamino implementation --}
let $pos := xs:integer(count($q[. <= $name]))
{-- determine start position relative to “Peter” entry --}
let $startPos := max((1, $pos - $offset))
{-- determine end position relative to “Peter” entry --}
let $endPos := min((count($q),$pos + $offset))
return $q[position() >= $startPos and position() <= $endPos]
The query generates a sequence with an element for each distinct author. The element holds the author name and the required attributes.
After that the query determines the position of the “Peter” entry and the start and end position relative to the “Peter” entry determined by the offset (x) value.
Finally the query returns the interval specified by the start and end position.
Best regards,
Thorsten
#API-Management#Tamino#webMethods