preserves-path examples
This commit is contained in:
parent
00e31c0e29
commit
18ac916899
|
@ -114,3 +114,32 @@ documents in the sequence. (A flattened set doesn't make sense for
|
||||||
streaming since the input documents come in a sequence; if the inputs
|
streaming since the input documents come in a sequence; if the inputs
|
||||||
were treated as a set represented as a sequence, and outputs were
|
were treated as a set represented as a sequence, and outputs were
|
||||||
buffered in a single large set, that could work out...)
|
buffered in a single large set, that could work out...)
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Consider the following Preserves Path selectors, intended to run
|
||||||
|
against the [Preserves codec test suite document](tests/samples.pr):
|
||||||
|
|
||||||
|
- `.annotations ^ Documentation . 0 /`
|
||||||
|
|
||||||
|
This selects each of the elements (mostly text strings) in the list
|
||||||
|
of the `Documentation` record annotating the test suite document
|
||||||
|
itself.
|
||||||
|
|
||||||
|
First, `.annotations` focuses on the annotations of the document.
|
||||||
|
Then, `^ Documentation` selects only annotations that are records
|
||||||
|
with label `Documentation`. Then, `. 0` selects the first field in
|
||||||
|
each record. Finally, `/` replaces each selected value with a
|
||||||
|
sequence of its children.
|
||||||
|
|
||||||
|
- `// [.^ [= Test + = NondeterministicTest]] [. 1 rec]`
|
||||||
|
|
||||||
|
This selects every deterministic or nondeterministic test case
|
||||||
|
where the expected value is a record.
|
||||||
|
|
||||||
|
First, `//` recursively selects *every* descendant subvalue of the
|
||||||
|
root (inclusive). Then, two filters are applied, one after the
|
||||||
|
other. The first, `[.^ [= Test + = NondeterministicTest]]`, selects
|
||||||
|
record labels, and then filters out all but `Test` and
|
||||||
|
`NondeterministicTest`. Then, the second, `[. 1 rec]`, filters out
|
||||||
|
all but those where the second field is a record.
|
||||||
|
|
Loading…
Reference in New Issue