On Tue, Nov 10, 2009 at 6:22 PM, Stefan Behnel <stefan_ml@behnel.de> wrote:
Hi,

please, don't top-post.

Sorry, I didn't know what 'top-post' mean until you've asked me twice not to do it and I checked wikipedia.
 

The feature you want is not "apply_templates", as that just mimics the
behaviour of xsl:apply-templates in XSLT, i.e. you can't define which
template will be applied or which XSL tags will run. That feature is
currently not available (apart from creating a new stylesheet from the
content of the extension element and applying that to input_node, but
that's a clumsy and also incomplete solution).


That's sad. Do you think it's hard to implement this feature, are there libxml or libxslt limits that will not allow to do that? Maybe I could join in and dig a bit? Just don't know where to start. I hope it's not too complicated and it's possible - I have my problem's elegant solution, but it needs this feature.
 

> When I try input_node[0] instead of input_node:
>
>         results = self.apply_templates(context, input_node[0])
>         print results
>
> results is empty list.

You didn't show your input document, so I don't know what "input_node" or
"input_node[0]" actually are in your case.


My input document is just:

<dummy />
 

> 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.

--
Marat