Hi Finn,
if sequence does not matter, you can do as follows:
let $startpos := 2
let $resultsize := 2
{-- First determine total number of hits --}
let $matches:= for $b in input()/J
where tf:containsText($b/F,"deltid") and tf:containsText($b/F,"ansvarsbevidst")
return $b
let $x := count ($matches)
{-- Make a resultset in $items with startpos, resultsize --}
let $items := ($matches)[position() >= $startpos and position() < $startpos + $resultsize]
{-- Iterate through resultset and return documents and add x and y as attributes to element --}
for $i in 1 to count($items)
{-- And this is where I would like to set the text-content of the element JOBTYPE somthing like:
let $items[$i]/JOBTYPE := 'TEXT FROM JOIN' --}
return <J>{$items[$i]/@*,$items[$i]/node() except $items[$i]/JOBTYPE,<JOBTYPE>TEXT FROM JOIN</JOBTYPE> }</J>
if sequence matters, try:
let $startpos := 2
let $resultsize := 2
{-- First determine total number of hits --}
let $matches:= for $b in input()/J
where tf:containsText($b/F,"deltid") and tf:containsText($b/F,"ansvarsbevidst")
return $b
let $x := count ($matches)
{-- Make a resultset in $items with startpos, resultsize --}
let $items := ($matches)[position() >= $startpos and position() < $startpos + $resultsize]
{-- Iterate through resultset and return documents and add x and y as attributes to element --}
for $i in 1 to count($items)
{-- And this is where I would like to set the text-content of the element JOBTYPE somthing like:
let $items[$i]/JOBTYPE := 'TEXT FROM JOIN' --}
return <J>{$items[$i]/@*,for $n in $items[$i]/node() return if (local-name($n)="JOBTYPE") then <JOBTYPE>TEXT FROM JOIN</JOBTYPE> else $n}</J>
or - even more generic
let $startpos := 2
let $resultsize := 2
{-- First determine total number of hits --}
let $matches:= for $b in input()/J
where tf:containsText($b/F,"deltid") and tf:containsText($b/F,"ansvarsbevidst")
return $b
let $x := count ($matches)
{-- Make a resultset in $items with startpos, resultsize --}
let $items := ($matches)[position() >= $startpos and position() < $startpos + $resultsize]
{-- Iterate through resultset and return documents and add x and y as attributes to element --}
for $i in 1 to count($items)
{-- And this is where I would like to set the text-content of the element JOBTYPE somthing like:
let $items[$i]/JOBTYPE := 'TEXT FROM JOIN' --}
return element {node-name($items[$i])} {$items[$i]/@*,for $n in $items[$i]/node() return if (local-name($n)="JOBTYPE") then element {local-name($n)} {"TEXT FROM JOIN"} else $n}
Regards
Harald
#Tamino#API-Management#webMethods