Revision 4023
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/xml_func.py | ||
---|---|---|
136 | 136 |
# Function names must start with _ to avoid collisions with real tags |
137 | 137 |
# Functions take arguments (items) |
138 | 138 |
|
139 |
#### Structural |
|
140 |
|
|
141 |
def _ignore(items, node): |
|
142 |
'''Used to "comment out" an XML subtree''' |
|
143 |
return None |
|
144 |
funcs['_ignore'] = _ignore |
|
145 |
structural_funcs.add('_ignore') |
|
146 |
|
|
147 |
def _ref(items, node): |
|
148 |
'''Used to retrieve a value from another XML node |
|
149 |
@param items |
|
150 |
addr=<path> XPath to value, relative to the XML func's parent node |
|
151 |
''' |
|
152 |
items = dict(items) |
|
153 |
try: addr = items['addr'] |
|
154 |
except KeyError, e: raise SyntaxError(e) |
|
155 |
|
|
156 |
target = xpath.get_1(node.parentNode, addr) |
|
157 |
if target != None: value = xml_dom.value(target) |
|
158 |
else: |
|
159 |
warnings.warn(UserWarning('_ref: XPath reference target missing: ' |
|
160 |
+str(addr))) |
|
161 |
value = None |
|
162 |
|
|
163 |
return value |
|
164 |
funcs['_ref'] = _ref |
|
165 |
structural_funcs.add('_ref') |
|
166 |
|
|
167 | 139 |
#### Conditionals |
168 | 140 |
|
169 | 141 |
def _eq(items, node): |
Also available in: Unified diff
xml_func.py: Removed no longer used structural functions