Revision 758
Added by Aaron Marcuse-Kubitza about 13 years ago
lib/xpath.py | ||
---|---|---|
122 | 122 |
if not parser.str_(','): break |
123 | 123 |
return paths |
124 | 124 |
|
125 |
parser.str_('/') # optional leading / |
|
126 | 125 |
path = _path() |
127 | 126 |
parser.end() |
128 | 127 |
_cache[str_] = path |
129 | 128 |
return path |
130 | 129 |
|
131 |
instance_level = 1 |
|
130 |
instance_level = 1 # root's grandchildren
|
|
132 | 131 |
|
133 | 132 |
def obj(path): |
134 | 133 |
obj_path = copy.deepcopy(path[:instance_level+1]) |
... | ... | |
137 | 136 |
|
138 | 137 |
def set_id(path, id_, has_types=True): |
139 | 138 |
if has_types: id_level = instance_level |
140 |
else: id_level = 0 |
|
139 |
else: id_level = 0 # root's children |
|
140 |
if path[0].name == '.': id_level += 1 # explicit root element |
|
141 | 141 |
path[id_level].keys.append([XpathElem('id', id_, True)]) |
142 | 142 |
|
143 | 143 |
def is_id(path): return path[0].is_attr and path[0].name == 'id' |
Also available in: Unified diff
xpath.py: set_id(): Deal with XPaths with an