let $name:= request:get-parameter('name','') let $sd :=/SequenceDiagram[@name =$name] let $homesym :=' || ' let $leftsym := ' >> ' let $rightsym := ' << ' let $actors := $sd/cast/actor let $nactors := count($sd/cast/actor) let $width := concat(100 div $nactors,'%') return {for $a in $actors return } {for $x in $sd/trace/* return { if (name($x)='action') then let $p := index-of($actors/@name,$x/@at ) return ( for $i in (1 to $p - 1) return ) else if (name($x)='message') then let $pfrom := index-of($actors/@name,$x/@from ) let $pto := index-of($actors/@name,$x/@to) let $pfirst := min (($pfrom,$pto)) let $plast := max(($pfrom,$pto)) let $ltor := $pfrom = $pfirst let $text := if ($ltor) then concat($leftsym,$x/@text,$leftsym) else concat($rightsym,$x/@text,$rightsym) return ( for $i in (1 to $pfirst - 1) return , for $i in ($plast + 1 to $nactors) return }
{string($a/@name)}
, {if ($x/@url) then {string($x/@do)} else string($x/@do) } , {$text} { if ($x/@url) then Link else () } ) else () }