MCPcopy Create free account
hub / github.com/antchfx/xpath / Select

Method Select

query.go:157–199  ·  view source on GitHub ↗
(t iterator)

Source from the content-addressed store, hash-verified

155}
156
157func (a *ancestorQuery) Select(t iterator) NodeNavigator {
158 if a.table == nil {
159 a.table = make(map[uint64]bool)
160 }
161
162 for {
163 if a.iterator == nil {
164 node := a.Input.Select(t)
165 if node == nil {
166 return nil
167 }
168 // Reset position for a new input context node
169 a.pos = 0
170 first := true
171 node = node.Copy()
172 a.iterator = func() NodeNavigator {
173 if first {
174 first = false
175 if a.Self && a.Predicate(node) {
176 return node
177 }
178 }
179 for node.MoveToParent() {
180 if a.Predicate(node) {
181 return node
182 }
183 }
184 return nil
185 }
186 }
187
188 for node := a.iterator(); node != nil; node = a.iterator() {
189 node_id := getHashCode(node.Copy())
190 if _, ok := a.table[node_id]; !ok {
191 a.table[node_id] = true
192 // Increase position for each matched node in current input context
193 a.pos++
194 return node
195 }
196 }
197 a.iterator = nil
198 }
199}
200
201func (a *ancestorQuery) Evaluate(t iterator) interface{} {
202 a.Input.Evaluate(t)

Callers

nothing calls this directly

Calls 4

getHashCodeFunction · 0.85
SelectMethod · 0.65
CopyMethod · 0.65
MoveToParentMethod · 0.65

Tested by

no test coverage detected