Contexts and Traversal

Unless your specify otherwise, paths are interpreted relative to the current context. So in the previous example, where we were inside a collection called Projects and wanted to display the text field Name, we only needed to refer to name in the VaeQL expression.

To jump out of the current context, you may begin your VaeQL expression with a slash (/). In this example, we jump out of the context of the collection to get the name of the current president of the company, which is stored in a different structure:

<v:collection path="projects">
 <v:text path="/overall/current_president" /> is proud to announce our new project:
 <v:text path="name" />
</v:collection>

Rather than jumping fully out, you can also navigate relative to the current current. To go up a level in the path, use two dots (..). You may traverse up as many levels as you'd like. In this example, we render the artist and title of each song together, even though they're in different collections:

All songs:
<v:collection path="artists">
 <v:collection path="songs">
  <v:text path="../artist_name" /> - <v:text path="song_title" />
 </v:collection>
</v:collection>

You can also traverse downward (we'll explain the [1] and [2] in a bit):

<v:collection path="artists">
 Artist Name: <v:text path="artist_name" />
 Title of first song: <v:text path="songs/song_title[1]" />
 Title of second song: <v:text path="songs/song_title[2]" />
</v:collection>