Nov. 15, 2006
7:58 a.m.
Hi, Chas Emerick wrote:
One of the key features of lxml from our perspective is the stated availability of custom function bindings within xslt. However, we've run into some difficulty in implementing them. Here's a concise example.
First, we set up our custom function, nothing special:
from lxml import etree as ET ns = ET.FunctionNamespace(None) ns['testfunction'] = lambda dummy, *args: 'function args: %s' % str(args)
You should generally avoid using empty namespaces for functions. It's not a big deal to use a local fake namespace here, but it prevents you from running into a number of difficult to track down problems. Could you retry with an explicit namespace and report back if that also fails? Stefan