Revision 78
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/xpath.py | ||
---|---|---|
14 | 14 |
self.attrs = attrs |
15 | 15 |
self.is_attr = is_attr |
16 | 16 |
self.is_ptr = is_ptr |
17 |
self.other_branches = [] # temp implementation for split paths |
|
17 | 18 |
|
18 | 19 |
def __repr__(self): |
19 | 20 |
str_ = '' |
... | ... | |
44 | 45 |
while True: |
45 | 46 |
# Split path |
46 | 47 |
if parser.str_('{'): |
47 |
paths = []
|
|
48 |
paths = tree[-1].other_branches
|
|
48 | 49 |
while True: |
49 |
paths.append(tree + _path())
|
|
50 |
paths.append(_path()) |
|
50 | 51 |
if not parser.str_(','): break |
51 | 52 |
parser.str_('}', required=True) |
52 |
tree = paths[0] # just use first subpath for now
|
|
53 |
tree += paths.pop(0) # use first subpath for now
|
|
53 | 54 |
break # nothing allowed after split path |
54 | 55 |
|
55 | 56 |
elem = XpathElem(is_attr=parser.str_('@'), |
... | ... | |
150 | 151 |
if elem.value != None: xml_dom.set_value(doc, node, elem.value) |
151 | 152 |
for attr in elem.attrs: get(doc, attr, create, last_only, node) |
152 | 153 |
|
154 |
for branch in elem.other_branches: |
|
155 |
set_value(branch, value(xpath)) |
|
156 |
get(doc, branch, create, last_only, node) |
|
157 |
|
|
153 | 158 |
# Follow pointer |
154 | 159 |
if elem.is_ptr: |
155 | 160 |
xpath = copy.deepcopy(xpath[elem_idx+1:]) # rest of XPath |
Also available in: Unified diff
xpath.py: Added basic support for split paths