<commit_before>angular.module('ngXslt', [])
    .filter('xslt', [
        '$window', '$document',
        function ($window, $document) {
            /**
             * Returns whether the browser supports XSLT.
             *
             * @return the browser supports XSLT
             * @type boolean
             */
            function browserSupportsXSLT () {
                if ($document.recalc) // IE 5+
                    return true;
                else if (angular.isDefined($window.XMLHttpRequest) && angular.isDefined($window.XSLTProcessor)) { // Mozilla 0.9.4+, Opera 9+
                    if (typeof (new XSLTProcessor()).transformDocument === 'function')
                        return angular.isDefined($window.XMLSerializer);

                    return true;
                }
                return false;
            }

            return function (xml, xslt) {
                if(!xml || !xslt)
                    return ('No' + (!xml ? ' XML' : '') + (!xml && !xslt ? ' &' : '') + (!xslt ? ' XSLT' : '')).trim();

                if (!browserSupportsXSLT())
                    return 'Not supported by your browser';

                xml = (new DOMParser()).parseFromString(xml, 'text/xml');
                if(xml.getElementsByTagName('parsererror')[0])
                    return 'Invalid XML';

                xslt = (new DOMParser()).parseFromString(xslt, 'text/xml');

                var processor = new XSLTProcessor();

                var output;
                if (typeof processor.transformDocument === 'function') { // obsolete Mozilla interface
                    output = document.implementation.createDocument("", "", null);
                    processor.transformDocument(xml, xslt, output, null);
                    return (new XMLSerializer()).serializeToString(output);
                } else {
                    processor.importStylesheet(xslt);
                    output = processor.transformToFragment(xml, document);

                    if(!output)
                        return 'Invalid XSLT';

                    var div = document.createElement('div');
                    div.appendChild(output);
                    return div.innerHTML;
                }
            }
        }]);<commit_msg>Add support for Internet Explorer.<commit_after>angular.module('ngXslt', [])
    .filter('xslt', [
        '$window', '$document',
        function ($window, $document) {
            /**
             * Returns whether the browser supports XSLT.
             *
             * @return the browser supports XSLT
             * @type boolean
             */
            function browserSupportsXSLT () {
                if ('ActiveXObject' in $window)
                    return true;
                else if (angular.isDefined($window.XMLHttpRequest) && angular.isDefined($window.XSLTProcessor)) { // Mozilla 0.9.4+, Opera 9+
                    if (typeof (new XSLTProcessor()).transformDocument === 'function')
                        return angular.isDefined($window.XMLSerializer);

                    return true;
                }
                return false;
            }

            return function (xml, xslt) {
                if(!xml || !xslt)
                    return ('No' + (!xml ? ' XML' : '') + (!xml && !xslt ? ' &' : '') + (!xslt ? ' XSLT' : '')).trim();

                if (!browserSupportsXSLT())
                    return 'Not supported by your browser';

                xml = (new DOMParser()).parseFromString(xml, 'text/xml');
                if(xml.getElementsByTagName('parsererror')[0])
                    return 'Invalid XML';

                if ('ActiveXObject' in $window) {
                    var trans = new ActiveXObject("Msxml2.XSLTemplate"),
                        xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument");
                    xslDoc.loadXML(xslt);
                    trans.stylesheet = xslDoc;
                    var proc = trans.createProcessor()
                    proc.input = xml;
                    proc.transform();
                    return proc.output;
                }

                xslt = (new DOMParser()).parseFromString(xslt, 'text/xml');

                var processor = new XSLTProcessor();

                var output;
                if (typeof processor.transformDocument === 'function') { // obsolete Mozilla interface
                    output = document.implementation.createDocument("", "", null);
                    processor.transformDocument(xml, xslt, output, null);
                    return (new XMLSerializer()).serializeToString(output);
                } else {
                    processor.importStylesheet(xslt);
                    output = processor.transformToFragment(xml, document);

                    if(!output)
                        return 'Invalid XSLT';

                    var div = document.createElement('div');
                    div.appendChild(output);
                    return div.innerHTML;
                }
            }
        }]);
{'fraction_non_alphanumeric': 0.11760031783869686, 'fraction_numerical': 0.002582439411998411, 'mean_word_length': 1.3772426817752597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 25}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1014925', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1143, 'n_words': 266}