Thanks for reply. It looks like it's not working as expected.
Hi,
please don't top-post.
Marat Dakota, 09.11.2009 10:13:
> Than it looks like I don't completely understand how it works. Could youAh, yes, attributes. Attributes are mapped to smart strings when passed
> 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>
through Python code.
Remember that self_node is the extension element itself. It will not change
> Function is:
>
> def execute(self, context, self_node, input_node, output_parent):
> ?????
> print etree.tostring(deepcopy(self_node))
during the evaluation, so printing it is uninteresting.
I would guess that you want to call it on "input_node". Calling
> 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).
.apply_templates() should return a string (although I never tested that),
which you can then add as a new attribute to the tree. You have to do that
manually, though. I would expect that "is_attribute" flag of the smart
string to be True in your case (see the XPath docs), that would allow you
to distinguish attributes from plain text context.
Stefan