XQuery is a query language that offers the ability to quickly and easily retrieve XML resources for rendering and presentation. Callimachus Layouts are XQuery files that provide a template for how content should be displayed.

The most common usage of XQuery files is as the Callimachus Layout. There are a number of very useful functions defined in the Callimachus XQuery Reference, many of which are used in the default layout.

Pragma Description
?results Evaluates this XQuery without an initial document
POST ?results Evaluates this XQuery using the request body as input

XQuery can also be used to format results, such as listings the unique speakers in each act of Shakespeare's play Hamlet, encoded in hamlet.xml.

   for $act in doc("hamlet.xml")//ACT
   let $speakers := distinct-values($act//SPEAKER)
       <h1>{ string($act/TITLE) }</h1>
         for $speaker in $speakers
         return <li>{ $speaker }</li>