summaryrefslogtreecommitdiff
path: root/addons/analytic_user_function/analytic_user_function_view.xml
diff options
context:
space:
mode:
authorXavier Morel <xmo@openerp.com>2014-04-15 16:56:59 +0200
committerXavier Morel <xmo@openerp.com>2014-05-19 08:32:23 +0200
commit9cefa76988ff94c3d590c6631b604755114d0297 (patch)
tree94a038128c0694c20eb24b8d3317c7c809213fdb /addons/analytic_user_function/analytic_user_function_view.xml
parent9a1413576a1601b004234413efd62c30d99d3822 (diff)
[ADD] hasclass() xpath function
Server-side, view extension is done via xpath. This includes "template" views full of HTML. HTML elements often have a bunch of classes, sometimes even semantic (!). XPath is generally great, but specifically lousy at dealing with space-separated values: in standard XPath 1.0 to know if an element has a class 'foo' the predicate is: contains(concat(' ', normalize-space(@class), ' '), ' foo ') and this has to be fully duplicated if there's a second class involved. Things are slightly better with EXSLT/XPath 2.0 and tokenize, but still not great: tokenize(@class, '\s+') = 'foo' and the equality check is very weird when unaware of XPath's evaluation rules. ``hasclass`` makes this much simpler to deal with: to get any ``foo`` node with the class ``bar`` is as simple as: //foo[hasclass('bar') and it can take multiple class, as with e.g. jquery it will return elements with all specified classes. Beware though, the predicate function will be called once for each element to check, since it's implemented in pure python and not profiled elements should be filtered as much as possible before this point.
Diffstat (limited to 'addons/analytic_user_function/analytic_user_function_view.xml')
0 files changed, 0 insertions, 0 deletions