Revision 2017
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/xml_func.py | ||
---|---|---|
3 | 3 |
import datetime |
4 | 4 |
import re |
5 | 5 |
import sre_constants |
6 |
import warnings |
|
6 | 7 |
|
7 | 8 |
import angles |
8 | 9 |
import dates |
... | ... | |
86 | 87 |
|
87 | 88 |
#### General |
88 | 89 |
|
89 |
def _ignore(items, self):
|
|
90 |
def _ignore(items, node):
|
|
90 | 91 |
'''Used to "comment out" an XML subtree''' |
91 | 92 |
return None |
92 | 93 |
funcs['_ignore'] = _ignore |
93 | 94 |
|
95 |
def _ref(items, node): |
|
96 |
'''Used to retrieve a value from another XML node |
|
97 |
@param items |
|
98 |
addr=<path> XPath to value, relative to the XML func's parent node |
|
99 |
''' |
|
100 |
items = dict(items) |
|
101 |
try: addr = items['addr'] |
|
102 |
except KeyError, e: raise SyntaxError(e) |
|
103 |
|
|
104 |
value = xpath.get_value(node.parentNode, addr) |
|
105 |
if value == None: |
|
106 |
warnings.warn(UserWarning('_ref: XPath reference target missing: ' |
|
107 |
+str(addr))) |
|
108 |
return value |
|
109 |
funcs['_ref'] = _ref |
|
110 |
|
|
94 | 111 |
#### Conditionals |
95 | 112 |
|
96 | 113 |
def _eq(items, node): |
Also available in: Unified diff
xml_func.py: Added _ref to retrieve a value from another XML node