类型不匹配错误:xsl为null

时间:2012-10-22 10:45:39

标签: c# xslt

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

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

0 个答案:

没有答案