forEachNodeIn

fun forEachNodeIn(document: Variant, sink: (VariantNode) -> Unit)

Every node document holds at this query's locations, in RFC 9535's nodelist order.

A sink, not a Sequence, and for the same reason CatalogPath.forEachNodeIn is one. VariantNode.value is a view over the bytes it was built from, so a lazy sequence would let one escape the snapshot that maps them — a read of freed memory, or on Windows a mapping that then cannot be unmapped. The nodes are valid for the duration of the call; anything kept beyond it must be copied, with Variant.toByteArray. VariantNode.location is an ordinary value and outlives everything.

The walk carries no depth, breadth or path budget and must not acquire one: a truncated nodelist is a wrong answer with nothing to say so. The bounds are on the query instead, and compile applies them.

Throws

if the document's bytes do not decode. A value the engine cannot read is reported, never skipped.