XSLT does not work in web browser

I have an XSLT file for styles in XML. XSLT is accessible via URL ( http: //someurl/somefile.xsl ) without any problems.

When I paste the same URL into the processing instruction xml-stylesheet, it only displays plain text in browsers (FF, IE),

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://someurl/somefile.xsl"?>
<rootElement>...</rootElement>

but when I use the local file path (the file is uploaded to the same folder as the XML file), it works like a charm:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="somefile.xsl"?>
<rootElement>...</rootElement>

Why?

+3
source share
2 answers

Running XSLT in a web browser

Running XSLT in a browser depends on some restrictions:

  • XSLT 2.0 is not supported by any of the major web browsers.

  • Browser security models vary with regard to XSLT processing.

XSLT , .

XSLT Chrome, Firefox IE,

  • XSLT 1.0, XSLT 2.0.
  • xml-stylesheet XML, , XSLT XML :

    <?xml version="1.0" encoding="UTF-8"?>
    <?xml-stylesheet type="text/xsl" href="http://origin-domain/path/to/file.xsl"?>
    <rootElement>...</rootElement>
    
  • XSLT , .
  • , XSLT , XML.

, . , IE , XSLT :

enter image description here

+5

, : XSLT 3.0 , Saxon-JS. , XSLT-, .

+1

Source: https://habr.com/ru/post/1622261/


All Articles