开发者

Caching client-side XSLT imports in Internet Explorer

I'm transforming an XML document with XSLT in Internet Explorer 7. My XSL开发者_如何学PythonT imports/includes -- I've tried both -- another XSLT with the following line:

<xsl:import href="utils.xsl" />

This results in an HTTP request for the included file every time the including XSLT is used, even if a reference to the parent XSLT is cached and re-used. IE sends a Pragma: no-cache header on each request for the import/include request.

Is it possible to prevent these repeated HTTP requests?

  • Can I get IE to cache the file in the client?
  • If not, can I get IE to send an "If-Modified-Since" header?

For completeness, here's the corresponding transformation JavaScript:

var XMLUtil = {

    // transforms the sourceStr using the given xslDoc
    transformString: function(sourceStr, xslDoc /*XMLDOM doc*/) {
        var sourceDoc = XMLUtil.loadFromString(sourceStr);
        var resultDoc = new ActiveXObject("Microsoft.XMLDOM");
        sourceDoc.transformNodeToObject(xslDoc, resultDoc);
        return resultDoc;
    },

    // creates an XMLDOM document from a string containing XML
    loadFromString: function(xml) {
        var doc = new ActiveXObject("Microsoft.XMLDOM");
        doc.async = false;
        doc.loadXML(xml);
        if (doc.parseError.errorCode != 0)
            throw "Error parsing XML: " + doc.parseError.errorCode;
        return doc;
    }

}


The responses to a similar question recommends setting ForcedResync to false.

But Qi Samuel Zhang's response cautions

ForcedResync should work for most cases, but the ForcedResync in MSXML3 has known issues to mitigate backward compatibility, please use MSXML2.DOMDocument.6.0 when possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜