xml/famXQ1.xq

(: xQuery has constructor for xml elements, and slightly different and extend syntax over xpath:)

declare variable $firstName as xs:string external;
<div>  {(: direct element constructor :)}
<h1>namen first = { $firstName } </h1>   {(: enclosed expressions in {} escape to an xquery expression :)}
<ol>
{//pers/<li> {string-join(text(), ' ')} </li> }
</ol>
<h2>order by</h2>
<ol>
{for $p in //pers order by string($p) descending return $p/(<li> {string-join(text(), ' ')} </li> )}
</ol>
</div>