We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51328
    • 13 Posts
    I tried to get the example on http://www.w3schools.com/xsl/xsl_client.asp to work on a revo 2.5.0 installation. I can't get it to work. When I try to access the xsl file (http://c0378.paas1.fra.modxcloud.com/assets/xsl/cdcatalog.xsl) it wants to download the file. When I access http://www.w3schools.com/xsl/cdcatalog.xsl it shows me the file in a tree structure.

    Here is the link to the page http://c0378.paas1.fra.modxcloud.com/movies.html

    What am I doing wrong?

    Edit: With a local revo 2.4.4 installation it works and I see the table

    This question has been answered by sabboooo. See the first response.

    [ed. note: sabboooo last edited this post 10 years, 4 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      You should set the Resource Type to be XML and the Content Disposition to be Inline. You will need to create the xsl Resource Type in Content -> Content Types, then use that for the .xsl resource's type.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 51328
        • 13 Posts
        I uploaded cdcatalog.xsl and cdcatalog.xml to assets/xsl and assets/xml. Then I created a html resource and used a template with this content:

         <html>
        <head>
        <base href="[[!++site_url]]" />
        <script>
        function loadXMLDoc(filename)
        {
        if (window.ActiveXObject)
          {
          xhttp = new ActiveXObject("Msxml2.XMLHTTP");
          }
        else
          {
          xhttp = new XMLHttpRequest();
          }
        xhttp.open("GET", filename, false);
        try {xhttp.responseType = "msxml-document"} catch(err) {} // Helping IE11
        xhttp.send("");
        return xhttp.responseXML;
        }
        
        function displayResult()
        {
        xml = loadXMLDoc("assets/xml/cdcatalog.xml");
        xsl = loadXMLDoc("assets/xsl/cdcatalog.xsl");
        // code for IE
        if (window.ActiveXObject || xhttp.responseType == "msxml-document")
          {
          ex = xml.transformNode(xsl);
          document.getElementById("example").innerHTML = ex;
          }
        // code for Chrome, Firefox, Opera, etc.
        else if (document.implementation && document.implementation.createDocument)
          {
          xsltProcessor = new XSLTProcessor();
          xsltProcessor.importStylesheet(xsl);
          resultDocument = xsltProcessor.transformToFragment(xml, document);
          document.getElementById("example").appendChild(resultDocument);
          }
        }
        </script>
        </head>
        <body onload="displayResult()">
        <div id="example" />
        </body>
        </html>


        On a local modx installation it works. But on a modx cloud installation I get a blank page. Changing the resource type doesn't help. Thanks anyways
        • discuss.answer
          • 51328
          • 13 Posts
          Solved it by renaming the extension of cdcatalog.xsl to cdcatalog.xml. Doesn't make sense to me but now it works.