(: Build a portfolio of paper titles per author. Over bibliography.xml. parke godfrey 2013-11-05 This demonstrates a query wiht nested FORs. The outer FOR gets the authors. The inner FOR then collects the papers by that author. There are various functions to retrieve the contents or values of a node. You see three main functions for this often. * text() : Concatenates all free text pieces within the node, trimming away child nodes. Does not recurse within child nodes for their text pieces. * string() : Concatenates all free text pieces within the node, trimming away child nodes. Does recurse within child nodes for their text pieces. * data() : Like strin(), but can return a list of strings if applied to an argument that results in more than one node or value. Note there is a problem with this solution. For an author who appears more than once in the document, we report a portfolio for that author for each occurence. How could we report just one portfolio for each author? :) { for $author in doc("bibliography.xml")//author order by $author return { for $paper in doc("bibliography.xml")//paper[.//author = $author] return $paper/title } }