Menu

#42 XSLTProcessor.importStylesheet fails for xsl:include case

open
nobody
None
5
2006-08-22
2006-08-22
No

Not sure whether this is related to 1541043, but it
happens in the same place.

This test in XSLTProcessor.importStylesheet is never true:

if( xslDoc.url &&
xslDoc.selectSingleNode("//xsl:*[local-name() =
'import' or local-name() = 'include']") != null){
converted.async = false;
converted.load(xslDoc.url);
} else {
converted.loadXML(xslDoc.xml);
};

The problem is that xslDoc.url is always empty even
when retrived using XmlHttpRequest. It's a known MS bug:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;234460

Discussion

  • Emmanuil Batsis (Manos)

    Logged In: YES
    user_id=542984

    well without the URL i cant really do anything :-/

    what would you propose?

     
  • Emmanuil Batsis (Manos)

    Logged In: YES
    user_id=542984

    what if xml:base was used in the XSL markup instead?

    http://www.w3.org/TR/xmlbase/#syntax

     
  • Andrew V.

    Andrew V. - 2006-12-06

    Logged In: YES
    user_id=1464381
    Originator: NO

    This code fails when "text.xslt" contains xsl:include or xsl:import
    Most interesting, that it works fine, when I load xslt document by deprecated Document.load() method.

    function TestOnLoad(){
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.open("GET", "test.xslt", false);
    xmlhttp.send(null);
    var xsltDoc = xmlhttp.responseXML;
    var xslProc = new XSLTProcessor();
    xslProc.importStylesheet(xsltDoc);
    }

    -- test.xslt ---------
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    <xsl:import href="test1.xslt"/>
    <xsl:template match="/">
    <xsl:apply-templates/>
    </xsl:template>

    </xsl:stylesheet>

    -- test1.xslt --------
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
    </xsl:stylesheet>

     
  • Andrew V.

    Andrew V. - 2006-12-06

    Logged In: YES
    user_id=1464381
    Originator: NO

    It crashes at line 198 of sarissa.js with Error:Access denied for IE. Mozilla works fine.

     
  • Doug Domeny

    Doug Domeny - 2007-04-26

    Logged In: YES
    user_id=1545119
    Originator: NO

    Sarissa version 0.9.7.8 should fix the "Access is denied" error. The MSXML 6 has new security-related parameters that need to be set to allow xsl:include, xsl:import and document().

    This is also related to 1517504.

     
  • Nobody/Anonymous

    Logged In: NO

    Hey Doug, i'm very buzy but if you can provide some URLs for me on this params i'll take a look tommorow morning. If you provide a patch i will probably make a new release ;-)

    Thanks,

    Manos

     
  • Doug Domeny

    Doug Domeny - 2007-04-26

    Logged In: YES
    user_id=1545119
    Originator: NO

    Version 0.9.7.8 already includes those parameters (namely, resolveExternals and AllowDocumentFunction), unless xslDoc.url is empty.

    I have moved those settings outside of the condition that checks for import/include.

    CAUTION: I'm still developing, so this approach has not be completely vetted, but if it works, use it.

    This is from XSLTProcessor.prototype.importStylesheet in sarissa.js.

    var converted = new ActiveXObject(_SARISSA_THREADEDDOM_PROGID);

    /* BEGIN NEW */
    if (_SARISSA_THREADEDDOM_PROGID == "MSXML2.FreeThreadedDOMDocument.6.0") {
    converted.setProperty("AllowDocumentFunction", true);
    converted.setProperty("AllowXsltScript", true);
    converted.resolveExternals = true;
    }
    /* END NEW */

    // make included/imported stylesheets work if exist and xsl was originally loaded from url
    if(xslDoc.url && xslDoc.selectSingleNode("//xsl:*[local-name() = 'import' or local-name() = 'include']") != null){
    converted.async = false;

    /* THIS IS IN 0.9.7.8, BUT COMMENTED-OUT HERE BECAUSE IT IS MOVED ABOVE */
    //if (_SARISSA_THREADEDDOM_PROGID == "MSXML2.FreeThreadedDOMDocument.6.0") {
    // converted.setProperty("AllowDocumentFunction", true);
    // converted.resolveExternals = true;
    //}

    converted.load(xslDoc.url);
    } else {
    converted.loadXML(xslDoc.xml);
    };

     

Log in to post a comment.

MongoDB Logo MongoDB