<!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('<a><b>B</b></a>')<br> style = self.parse('''\<br><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"><br> <xsl:template match="a"><br> <xsl:variable name="content"><br> <xsl:apply-templates/><br> </xsl:variable><br> <A><xsl:value-of select="myns:mytext($content)"/></A><br> </xsl:template><br></xsl:stylesheet>''')<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('<A>X</A>'))<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> </p><p>In the stylesheet, your selection of content into the "content" XSLT variable does not</p><p>work. </p><p>Try s.th. like</p><p> </p><p> style = self.parse('''\<br><xsl:stylesheet version="1.0"<br> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"<br> xmlns:myns="testns"<br> exclude-result-prefixes="myns"><br> <xsl:template match="a"><br> <xsl:variable name="content" select="*"/><br> <A><xsl:value-of select="myns:mytext($content)"/></A><br> </xsl:template><br></xsl:stylesheet>''')<br> <br> Cheers,</p><p>Holger </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>