<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html><head><style>p {margin:0px;padding:0px;} blockquote { border: 0px; margin-top: 0px; margin-bottom: 0px; }</style></head><body style="">
<p>Hi,<br><font color="#000000" face="Verdana" size="2"><br><blockquote type="cite">    def test_extensions3(self):<br>        tree = self.parse('&lt;a&gt;&lt;b&gt;B&lt;/b&gt;&lt;/a&gt;')<br>        style = self.parse('''\<br>&lt;xsl:stylesheet version="1.0"<br>    xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform%22">http://www.w3.org/1999/XSL/Transform"</a><br>    xmlns:myns="testns"<br>    exclude-result-prefixes="myns"&gt;<br>  &lt;xsl:template match="a"&gt;<br>    &lt;xsl:variable name="content"&gt;<br>       &lt;xsl:apply-templates/&gt;<br>    &lt;/xsl:variable&gt;<br>    &lt;A&gt;&lt;xsl:value-of select="myns:mytext($content)"/&gt;&lt;/A&gt;<br>  &lt;/xsl:template&gt;<br>&lt;/xsl:stylesheet&gt;''')<br><br>        def mytext(ctxt, values):<br>            return 'X' * len(values)<br><br>        namespace = etree.FunctionNamespace('testns')<br>        namespace['mytext'] = mytext<br><br>        result = tree.xslt(style)<br>        self.assertEquals(self._rootstring(result),<br>                          _bytes('&lt;A&gt;X&lt;/A&gt;'))<br><br>Actually, the function test_extensions3() is derived from test_extensions2. The<br>only difference is the variable content which is passed on to the extension<br>function. I've expected an identical result like test_extensions2. From what<br>I know, I think it is a common approach to collect the content in a variable<br>and pass it on to other functions.<br><br>[...]<br><br>Any hints what I'm doing wrong?<br></blockquote></font></p><p>&nbsp;</p><p>In the stylesheet, your selection of content into the "content" XSLT variable does not</p><p>work.&nbsp;</p><p>Try s.th. like</p><p>&nbsp;</p><p>&nbsp;&nbsp;&nbsp; style = self.parse('''\<br>&lt;xsl:stylesheet version="1.0"<br>&nbsp;&nbsp;&nbsp; xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br>&nbsp;&nbsp;&nbsp; xmlns:myns="testns"<br>&nbsp;&nbsp;&nbsp; exclude-result-prefixes="myns"&gt;<br>&nbsp; &lt;xsl:template match="a"&gt;<br>&nbsp;&nbsp;&nbsp; &lt;xsl:variable name="content" select="*"/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;A&gt;&lt;xsl:value-of select="myns:mytext($content)"/&gt;&lt;/A&gt;<br>&nbsp; &lt;/xsl:template&gt;<br>&lt;/xsl:stylesheet&gt;''')<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;Cheers,</p><p>Holger&nbsp;</p><div class="signature"><br /><br /><br />-- <br />Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! <br />Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer</div></body></html>