Emanuele D'Arrigo wrote:
I didn't know it was possible to apply an xslt transformation to an element! That's exactly what I was after! It's true, the API<http://codespeak.net/lxml/api/lxml.etree.XSLT-class.html>clearly states: "Calling this object on a tree or Element will execute the XSLT". I just had no idea about it because I only looked here<http://codespeak.net/lxml/api/index.html>and all examples refer to ElementTree objects being the input to XSLT objects. Might be good to add an Element example or change an existing one to handle an element.
Thank you though, this is really good news!
... not as good as that. I just checked, and it actually decouples the element from the rest of the document before running the XSLT. So that won't help in the case that the XSLT needs to refer to the ancestors. I wonder if it would make sense to disable the decoupling for plain Elements. The problem is that this might break code. OTOH, I expect little XSLT code to really depend on this, and it's easy to work around by wrapping the element in an ElementTree object. Stefan