#NEWLINE# def test_variable_result_tree_fragment( self ) : #NEWLINE# #INDENT# tree = self . parse ( '<a><b>B</b><b/></a>' ) #NEWLINE# style = self . parse ( '<xsl:stylesheet version="1.0"\n    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"\n    xmlns:myns="testns"\n    exclude-result-prefixes="myns">\n  <xsl:template match="a">\n    <xsl:variable name="content">\n       <xsl:apply-templates/>\n    </xsl:variable>\n    <A><xsl:value-of select="myns:mytext($content)"/></A>\n  </xsl:template>\n  <xsl:template match="b"><xsl:copy>BBB</xsl:copy></xsl:template>\n</xsl:stylesheet>' ) #NEWLINE# def mytext( ctxt , values ) : #NEWLINE# #INDENT# for value in values : #NEWLINE# #INDENT# self . assertTrue ( hasattr ( value , 'tag' ) , ( '%s is not an Element' % type ( value ) ) ) #NEWLINE# self . assertEqual ( value . tag , 'b' ) #NEWLINE# self . assertEqual ( value . text , 'BBB' ) #NEWLINE# #UNINDENT# return 'X' . join ( [ el . tag for el in values ] ) #NEWLINE# #UNINDENT# namespace = etree . FunctionNamespace ( 'testns' ) #NEWLINE# namespace [ 'mytext' ] = mytext #NEWLINE# result = tree . xslt ( style ) #NEWLINE# self . assertEqual ( self . _rootstring ( result ) , _bytes ( '<A>bXb</A>' ) )