@verb #962:":xpath" this none this rxdo #55 @program #962:":xpath" this none this {path} = args "If we had a 'doc' pointer than '/foo' would start at the root, but, well, we don't." match(path, "^/") && raise(E_INVARG, "Relative paths only, please") re = $regexp:new("^%([^[/]+%)%(%[[^]]+%]%)*%(/%([^[/]+%)%(%(%[[^]]+%]%)*%)%(.*%)%)$") re->exec(path) {me, myspec, next, spec, rest} = {re->_1, re->_2, re->_4, re->_5, re->_7} if (myspec) raise(E_INVARG, "Queries on current node are not permitted.") elseif (!next) return this endif "Filter out child nodes with the wrong name" if (next == "*") search = this->children elseif (next[1] == "@") return `this->get_attribute(next[2..$]) ! E_PROPNF, E_RANGE => ""' else search = {} for x in (this->children) if (typeof(x) != WAIF) continue endif if (x->name == next) search = {@search, x} endif endfor endif specre = $regexp:new("^%[%([^]]+%)%]") while (specre->exec(spec)) s = specre->_1 spec = specre->rightContext if ($string_utils:is_numeric(s)) if (toint(s) < 1 || toint(s) > length(search)) search = {} else search = search[toint(s)..toint(s)] endif elseif ((re = $regexp:new("^@%([^=]+%)%(=\"%([^\"]+%)\"%)?")) || re->exec(s)) {name, value} = {re->_1, re->_3} newsearch = {} for x in (search) a = `x->get_attribute(name) ! E_PROPNF' if (a == E_PROPNF) elseif (value && a != value) else newsearch = {@newsearch, x} endif endfor search = newsearch endif endwhile r = {} for x in (search) if (rest) r = {@r, @x->xpath(tostr(next, rest))} else r = {@r, x} endif endfor return length(r) == 1 ? r[1] | r "Last modified by whiz (#3135) on Mon Aug 12 13:37:24 2002 MDT." "This verb previously owned by manta (#7165), and chowned to $slacker upon dewizarding (Sat Aug 17 14:50:06 2002 MDT)." "Last modified by Dax (#789) on Tue May 3 14:14:11 2005 MDT." .