Previous Next JavaScript must be enabled to correctly display this content

## Path Expressions

Syntax

    path_expression ::= primary_expression (map_step | array_step)*

    map_step ::= "." (map_filter_step | map_field_step)

    array_step ::= array_filter_step | array_slice_step

Semantics

Path expressions are used to navigate inside hierarchically structured data. As shown in the syntax, a path expression has an input expression (which is one of the primary expressions described in the Primary Expressions section, followed by one or more steps. The input expression may return any sequence of items. Each step is actually an expression by itself; It takes as input a sequence of items and produces zero or more items, which serve as the input to the next step, if any. Each step creates a nested scope, which covers just the step itself.

All steps iterate over their input sequence, producing zero or more items for each input item. If the input sequence is empty, the result of the step is also empty. Otherwise, the overall result of the step is the concatenation of the results produced for each input item. The input item that a step is currently operating on is called the context item, and it is available within the step expression via an implicitly-declared variable, whose name is a single dollar sign ($). This context-item variable exists in the scope created by the step expression.

There are several kinds of steps. For all of them, if the context item is NULL, it is just added into the output sequence with no further processing. Otherwise, the following subsections describe the operation performed by each kind of step on each non-NULL context item.