
Am I asking something wrong or something too obvious to answer? On Mon, Nov 9, 2009 at 12:13 PM, Marat Dakota <dakota@brokenpipe.ru> wrote:
Than it looks like I don't completely understand how it works. Could you please help me:
XSLT file is:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:my="testns" extension-element-prefixes="my"> <xsl:template match="/"> <foo> <my:ext> <xsl:attribute name="test"><xsl:value-of select="111" /></xsl:attribute> blabla </my:ext> </foo> </xsl:template> </xsl:stylesheet>
Function is:
def execute(self, context, self_node, input_node, output_parent): ????? print etree.tostring(deepcopy(self_node))
What should I put instead of ????? to make self_node having attribute named test with "111" as value? I tried to call self.apply_templates for everything (for self_node, for self_node[0], even for input_node and output_parent). No result in either case, print result is the same:
<my:ext xmlns:my="testns" xmlns:xsl="http://www.w3.org/1999/XSL/Transform "> <xsl:attribute name="test"><xsl:value-of select="111"/></xsl:attribute> blabla </my:ext>
What am I doing wrong?
Thanks.
-- Marat
On Mon, Nov 9, 2009 at 10:44 AM, Stefan Behnel <stefan_ml@behnel.de>wrote:
Marat Dakota, 08.11.2009 23:28:
Hi, I have a problem I couldn't find the way to solve. Sadly if it's not possible.
That's the code from XSLT extensions tutorial:
<xsl:template match="*"> <my:python-extension> <some-content /> </my:python-extension> </xsl:template>
Everything's working cool, but I need a bit more:
<xsl:template match="*"> <my:python-extension> <something><xsl:attribute name="test"><xsl:value-of select="111" /></xsl:attribute></something> </my:python-extension> </xsl:template>
Let's assume that's my execute function's signature:
execute(self, context, self_node, input_node, output_parent)
When it's started by XSLT processor, self_node contains <something> tag with <xsl:attribute> and <xsl:value-of> tags inside it. What should I do to ask XSLT processor to evaluate it?
It's funny that you found the example above but didn't make it to the text sections right below it.
http://codespeak.net/lxml/extensions.html#applying-xsl-templates
Stefan