Project

General

Profile

« Previous | Next » 

Revision 754

xpath.py: Allow XPath names to be quoted literals, just like values. Handle : embedded in a name (even without quotes), often indicating a namespace.

View differences:

lib/xpath.py
66 66
                tree += tree[-1].other_branches.pop(0) # use first path for now
67 67
                break # nothing allowed after split path
68 68
            
69
            elem = XpathElem(is_attr=parser.str_('@'),
70
                name=parser.re(r'[\w.*]*', required=True))
69
            elem = XpathElem(is_attr=parser.str_('@'), name=_value())
71 70
            
72 71
            # Keys used to match nodes
73 72
            if parser.str_('['):
......
96 95
        tree[0].is_positive = is_positive
97 96
        
98 97
        # Value
99
        if parser.str_('='):
100
            if parser.str_('"'):
101
                value = parser.re(r'[^"]*')
102
                parser.str_('"', required=True)
103
            else: value = parser.re(r'[\w.]*')
104
            set_value(tree, value)
98
        if parser.str_('='): set_value(tree, _value())
105 99
        
106 100
        # Expand * abbrs
107 101
        for i in reversed(xrange(len(tree))):
......
114 108
        
115 109
        return tree
116 110
    
111
    def _value():
112
        if parser.str_('"'):
113
            value = parser.re(r'[^"]*')
114
            parser.str_('"', required=True)
115
        else: value = parser.re(r'(?:(?:\w+:)*[\w.*]+)?')
116
        return value
117
    
117 118
    def _paths():
118 119
        paths = []
119 120
        while True:

Also available in: Unified diff