def xsl_transform(self, filename=None, xsl=None, return_type=None, **params):
<EOL>if return_type is None:<EOL><INDENT>return_type = XmlObject<EOL><DEDENT>for key, val in six.iteritems(params):<EOL><INDENT>if isinstance(val, six.string_types):<EOL><INDENT>params[key] = etree.XSLT.strparam(val)<EOL><DEDENT><DEDENT>parser = _get_xmlparser()<EOL>if xsl is not None and isinstance(xsl, etree.XSLT):<EOL><INDENT>result = xsl(self.node, **params)<EOL><DEDENT>else:<EOL><INDENT>if filename is not None:<EOL><INDENT>xslt_doc = etree.parse(filename, parser=parser)<EOL><DEDENT>if xsl is not None:<EOL><INDENT>xslt_doc = etree.fromstring(xsl, parser=parser)<EOL><DEDENT>if self.node == self.node.getroottree().getroot():<EOL><INDENT>xmltree = self.node.getroottree()<EOL><DEDENT>else:<EOL><INDENT>partial_doc = etree.fromstring(self.serialize(), parser=parser)<EOL>xmltree = partial_doc.getroottree()<EOL><DEDENT>result = xmltree.xslt(xslt_doc, **params)<EOL><DEDENT>if issubclass(return_type, six.string_types):<EOL><INDENT>if result is None:<EOL><INDENT>logger.warning("<STR_LIT>")<EOL>return<EOL><DEDENT>else:<EOL><INDENT>return return_type(result)<EOL><DEDENT><DEDENT>if result is None or result.getroot() is None:<EOL><INDENT>logger.warning("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>return return_type(result.getroot())<EOL><DEDENT>
Run an xslt transform on the contents of the XmlObject.

        XSLT can be passed in as an XSLT object generated by :meth:`load_xslt`
        or as filename or string. If a params dictionary is specified, its items
        will be passed as parameters to the XSL transformation, and any string
        values will automatically be encoded as XSL string parameters.

        .. Note::

            If XSL is being used multiple times, it is recommended to
            use :meth`:load_xslt` to load and compile the XSLT once.

        :param filename: xslt filename (optional, one of file and xsl is required)
        :param xsl: xslt as string OR compiled XSLT object as returned by
            :meth:`load_xslt` (optional)
        :param return_type: type of object to return; optional, defaults to
            :class:`XmlObject`; specify unicode or string for text output
        :returns: an instance of :class:`XmlObject` or the return_type specified