0

我在此代码上遇到类型不匹配错误:

function xsltTransform(xmlPath, xslPath, parameter) {
    if (lastXMLloaded != xmlPath) {
        xml = loadXMLDoc(xmlPath);
        lastXMLloaded = xmlPath;
    }
    if (lastXSLloaded != xslPath) {
        xsl = loadXSLDoc(xslPath);
        lastXSLloaded = xslPath;
    }
    var param = parameter.split(";");
    var count = param.length;
    if (window.ActiveXObject) {
        var template = new ActiveXObject("MSXML2.XSLTemplate");
        template.stylesheet = xsl.documentElement;
        var xsltProcessor = template.createProcessor();
        xsltProcessor.input = xml;
        for (i = 0; i <= count - 1; i++) {
            var paramKeyValue = param[i].split(",");
            xsltProcessor.addParameter(paramKeyValue[0], paramKeyValue[1]);
        }
        xsltProcessor.transform();
        var result = xsltProcessor.output;
        return result;
    } else if (document.implementation && document.implementation.createDocument) {
        xsltProcessor = new XSLTProcessor();
        try {
            xsltProcessor.importStylesheet(xsl);
        } catch (e) {}
        for (i = 0; i <= count - 1; i++) {
            var paramKeyValue = param[i].split(",");
            xsltProcessor.setParameter(null, paramKeyValue[0], paramKeyValue[1]);
        }
        var resultDocument = xsltProcessor.transformToFragment(xml, document);
        return resultDocument
    }
}

这部分代码:template.stylesheet = xsl.documentElement;表示值为null.

4

0 回答 0