xquery version "1.0"; import module namespace saxonb = "http://cefn.com/saxonb/" at "../lib/libout.xquery"; declare namespace c="http://cefn.com/"; declare default element namespace "http://www.w3.org/1999/xhtml"; declare function c:writepage($href, $content, $menu){ saxonb:write-html($href,

widoh

{$content}
) }; declare function c:writelabel($node){
{if($node/@title) then (

{string($node/@title)}

) else ()} {if($node/@desc) then (

{string($node/@desc)}

) else ()}
}; declare function c:href($node as item()) as xs:string{ concat(local-name($node), '_', $node/@id, '.html') }; declare function c:writelist($nodes){ for $node in $nodes order by $node/@title return

{string($node/@title)}

}; let $source := doc('data.xml'), $allpages := $source//page, $allpersons := $source//person, $allprojects := $source//project, $defaultmenu :=

What I Did On Holiday

A collection of technology projects undertaken by BT employees in their spare time

, $peoplemenu :=

Widoh People

Anyone is welcome to present, so long as they have a technology project which they've undertaken in their spare time.

, $projectmenu :=

Widoh Projects

Whatever the technology project, the more playful the better. No business cases required.

return ( for $page in $allpages return c:writepage(c:href($page),$page/div[*], $defaultmenu) , for $person in $allpersons order by $person/@title return c:writepage(c:href($person),(c:writelabel($person),

Projects

{c:writelist($allprojects[contributor/@refid=$person/@id])}
, $person/div[*]), $peoplemenu), for $project in $allprojects return c:writepage(c:href($project),(c:writelabel($project),

Contributors

{c:writelist($allpersons[@id=$project/contributor/@refid])}
,$project/div[*]), $projectmenu), c:writepage('list_persons.html',
{c:writelist($allpersons)}
, $peoplemenu), c:writepage('list_projects.html', (for $date in distinct-values($allprojects/@presented) order by xs:date($date) descending return

{string($date)}

{c:writelist($allprojects[@presented=$date])}

), $projectmenu) )