(:
Find the first author per parent.
Over bibliography.xml.
parke godfrey 2013-11-05
Our query finding first authors again, but wrapped as a full-fledged
XQuery query. After the IN in a FOR clause comes the generator,
which is an XPath expression.
* All variables in XQuery start with a "$".
* "at" provides a counter (starting with "1"!) for the FOR iterator.
* "data(...)" extracts the data content of the node.
* The query includes a start tag and its end tag
in this case. This makes the query results a proper XML document
of its own.
* The "{...}" is used as an EVAL: evaluate the contents and return
the results.
* Note I wrap the results in the "return" to have the tags I decided
I wanted.
:)
{
for $first at $i in doc("bibliography.xml")//author[1]
return {$i}. {data($first)}
}