
Stefan Behnel, 10.11.2009 17:20:
Marat Dakota, 10.11.2009 16:58:
By the way, this simple code causes segmentation fault on my OSX, Linux and Windows machines.
class MyExtElement(etree.XSLTExtension): def execute(self, context, self_node, input_node, output_parent): print input_node
No idea why, I'll have to look into that.
My colleague traced it a bit. He was just very curious if it's python's segfault (which he never met and that's why he's curious) or lxml's one. He said lxml dies when trying to read property tag of input_node.
My guess is that input_node is not an element here but a different kind of XML node.
Yes, that was the reason. Template matching on "/" makes the *document node* the context node instead of the root node. While this is ok from the POV of XPath/XSLT, it doesn't make sense in lxml.etree. lxml 2.2.5 will no longer crash here (fix is committed) and lxml 2.3 will support other types of context nodes. Stefan