XPath Evaluation in Repeat Templates

Mark Birbeck's picture

The XML item that holds this data is the title attribute on each photo element. The XPath expression needed to refer to, say, the title of the third photo would be:

instance('inst-rs')/photos/photo[3]/@title

However, when we place controls into a repeat template, their XPath expressions are evaluated one at a time, in the context of each of the items in the list. So to show the title of each of the photos in the list, we need only do this:

      <xf:repeat nodeset="instance('inst-rs')/photos/photo">
        [<xf:output ref="@title" />]
      </xf:repeat>

Refresh the form, and try searching for something--you should see a list of image titles:

Screenshot of Flickr search form showing search results...but only the image titles