IE9 and Chrome not rendering XML with XSL if XML is local and XSL is on remote server

前端 未结 2 1807
无人及你
无人及你 2021-01-05 02:56

I have the following XML:



相关标签:
2条回答
  • 2021-01-05 03:26

    We have a desktop application that generates XML reports and displays them in a browser, transformed with stylesheets that are hosted on a remote server

    I think that simplest way is to download or store/cache (last copy of) stylesheet via HTTP protocol on user's local hard disk (using that application) and then perform "fully-legal" client-side transformation.

    0 讨论(0)
  • 2021-01-05 03:44

    Does this work locally? I do not think so because there are some errors in both XML and XSLT.

    Chrome blocks local XML and XSLT processing! It is a issue or they disabled it for security reasons. Look at this Chrome Bug Report for some work-arounds.

    IE9 disabled the support of mixture of local XML and remote XSLT. Also for security reasons! (I do not have a link for that)

    Your XML needs to have at least one root element:

    <?xml version="1.0"?>
    <?xml-stylesheet type="text/xsl" href="http://www.test.com/AuditTrail.xsl"?>
    <hello/>
    

    and your XSLT needs to have some XSLT templates:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
        <html>
        <head><title>Test</title></head>
        </html>
    </xsl:template>
    
    </xsl:stylesheet>
    

    With this corrections this example will work for IE8 and Firefox.
    In Chrome the XML and XSLT needs to be on a webserver. In IE9 both need to be on a webserver or locally stored (without mixture).

    0 讨论(0)
提交回复
热议问题