Exhibit/Expressions

From SIMILE Widgets
Jump to: navigation, search

Note: You should first read Exhibit/Understanding_Exhibit_Database.

Recall that data in a Exhibit database can be represented as a graph, e.g.,

Graph-based-model.jpg

Exhibit expressions are used mainly to move along paths through paths and items, such as the path depicted in the graph. That is, given some nodes in the graph (whether circles/items or arrows/properties), evaluating an Exhibit expression retrieves other nodes (items or properties) that are related.

Exhibit moves along such paths by means of expressions. At this time of writing, an Exhibit expression consists of a single path. A path consists of a sequence of one or more property IDs, each preceded by a hop operator. The . hop operator traverses along an arrow (forward, or away from an originating circle/item) while the ! hop operator traverses against an arrow (backward, or toward a circle/item).

For example, given the "The DaVinci Code" item node (the blue circle on the left in the graph above), evaluating .author.label returns "Dan Brown (writer)". Given the 6347343 value node, evaluating !number-of-copies-sold.author returns the item node "Dan Brown" (that is, you'll get the whole item/object, not just its name). Evaluating !number-of-copies-sold.author.id returns the value node "Dan Brown" (the id value, not the item itself).

Here are some more examples (you should be able to imagine for yourself, based on the wording of the properties, how the data might appear in a graph like the one above):

  • evaluating .hasAuthor.teachesAt.locatedIn on some papers returns the locations of the schools where the authors of those papers teach;
  • evaluating .spouseOf!parentOf on some people returns their parents-in-laws.
  • evaluating !shot!arrested on John F. Kennedy returns the police officers who arrested his assassinator.

A path can also start with one of a few predefined variables, currently including

  • value (referring to the current item or value on which the expression is being evaluated) and
  • index (referring to the index of the current item/value in a sequence of items/values)

value is understood if there is no such variable at the beginning of a path. That is, you can also write .spouseOf!parentOf as value.spouseOf!parentOf.

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox