def transform(self, tree, stylesheet_path, **args):
        """
            Transform an element tree with XSLT

            @param tree: the element tree
            @param stylesheet_path: pathname of the XSLT stylesheet
            @param args: dict of arguments to pass to the stylesheet
        """

        self.error = None

        if args:
            _args = dict((k, "'%s'" % args[k]) for k in args)
        else:
            _args = None

        if isinstance(stylesheet_path, (etree._ElementTree, etree._Element)):
            # Pre-parsed stylesheet
            stylesheet = stylesheet_path
        else:
            stylesheet = self.parse(stylesheet_path)

        if stylesheet is not None:
            try:
                ac = etree.XSLTAccessControl(read_file=True, read_network=True)
                transformer = etree.XSLT(stylesheet, access_control=ac)
                if _args:
                    result = transformer(tree, **_args)
                else:
                    result = transformer(tree)
                return result
            except:
                e = sys.exc_info()[1]
                self.error = e
                current.log.error(e)
                #output = self.tostring(tree, pretty_print=True)
                #outputFile = open("failed_transform.xml", "w")
                #outputFile.write(output)
                #outputFile.close()
                return None
        else:
            # Error parsing the XSL stylesheet
            return None

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3xml.py/S3XML.transform/original