MCPcopy Create free account
hub / github.com/beevik/etree / parsePath

Method parsePath

path.go:227–249  ·  view source on GitHub ↗

parsePath parses an XPath-like string describing a path through an element tree and returns a slice of segment descriptors.

(path string)

Source from the content-addressed store, hash-verified

225// through an element tree and returns a slice of segment
226// descriptors.
227func (c *compiler) parsePath(path string) []segment {
228 // If path ends with //, fix it
229 if strings.HasSuffix(path, "//") {
230 path += "*"
231 }
232
233 var segments []segment
234
235 // Check for an absolute path
236 if strings.HasPrefix(path, "/") {
237 segments = append(segments, segment{new(selectRoot), []filter{}})
238 path = path[1:]
239 }
240
241 // Split path into segments
242 for _, s := range splitPath(path) {
243 segments = append(segments, c.parseSegment(s))
244 if c.err != ErrPath("") {
245 break
246 }
247 }
248 return segments
249}
250
251func splitPath(path string) []string {
252 var pieces []string

Callers 1

CompilePathFunction · 0.95

Calls 3

parseSegmentMethod · 0.95
splitPathFunction · 0.85
ErrPathTypeAlias · 0.85

Tested by

no test coverage detected