Project

General

Profile

1
# XPath "function" elements that transform their subpaths
2

    
3
import xpath
4

    
5
##### Functions
6

    
7
funcs = {}
8

    
9
def process(path):
10
    if path == []: return path
11
    
12
    path[1:] = process(path[1:])
13
    name = path[0].name
14
    if name.startswith('_') and name in funcs: return funcs[name](path)
15
    else: return path
16

    
17
#### XPath functions
18

    
19
# Function names must start with _ to avoid collisions with real tags
20
# Functions take arguments (path)
21

    
22
def _for(items):
23
    return None
24
funcs['_for'] = _for
(17-17/17)