#NEWLINE# def test_extension_element_apply_templates_elements_only( self ) : #NEWLINE# #INDENT# tree = self . parse ( '<a><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    extension-element-prefixes="myns">\n  <xsl:template match="a">\n    <A><myns:myext><x>X</x><y>Y</y><z/></myns:myext></A>\n  </xsl:template>\n  <xsl:template match="x"><X/></xsl:template>\n  <xsl:template match="z">XYZ</xsl:template>\n</xsl:stylesheet>' ) #NEWLINE# class MyExt ( etree . XSLTExtension ) : #NEWLINE# #INDENT# def execute( self , context , self_node , input_node , output_parent ) : #NEWLINE# #INDENT# for child in self_node : #NEWLINE# #INDENT# for result in self . apply_templates ( context , child , elements_only = True ) : #NEWLINE# #INDENT# assert ( not isinstance ( result , basestring ) ) #NEWLINE# output_parent . append ( result ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# extensions = { #NEWLINE# #INDENT# ( 'testns' , 'myext' ) : MyExt ( ) , #NEWLINE# #UNINDENT# } #NEWLINE# result = tree . xslt ( style , extensions = extensions ) #NEWLINE# self . assertEqual ( self . _rootstring ( result ) , _bytes ( '<A><X/></A>' ) )