I have a XSLT sample copied straight from http://www.w3schools.com/xsl/xsl_transformation.asp, which I can't seem to view in Google Chrome. However, it seems to work fine in IE.
Does anyone know why this would be?
The online version works fine, but the local copy does not.
The reason this doesn't work is due to a security concern that Chrome has addressed in a controversial way, by blocking XML files from accessing local XSLT files in the same directory, while HTML files can access . CSS files in the same directory just fine.
Add the XSLT style sheet using the Properties window. With the XML file open in the editor, right-click anywhere in the editor and choose Properties. In the Properties window, click in the Stylesheet field and choose the browse button (...). Select the XSLT style sheet, and then choose Open.
Web browsers: Safari, Chrome, Firefox, Opera and Internet Explorer all support XSLT 1.0 (only). Browsers can perform on-the-fly transformations of XML files and display the transformation output in the browser window.
XSLT is very widely used. As far as we can judge from metrics like the number of StackOverflow questions, it is in the top 30 programming languages, which probably makes it the top data-model-specific programming language after SQL. But XSLT isn't widely used client-side, that is, in the browser.
I had same issue with Google Chrome (tested on 13.0.782.215) and (non-JavaScript XSL transformation):
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
I found solution that works for me is to run Chrome browser with --allow-file-access-from-files
switch:
// By default, file:// URIs cannot read other file:// URIs. This is an
// override for developers who need the old behavior for testing.
const char kAllowFileAccessFromFiles[] = "allow-file-access-from-files";
Yeah, if you copied the sample down to a file on your computer, the xml won't work with xslt on chromium because it can't find your xslt file provided by just its filename. I've tried put both the xml file and the xslt file to a web server running on my computer and it worked.
If you don't have a web server on your computer, I have no solution with chromium. But maybe you can try a full path, maybe begun with "file:///C:/". Use other browser if that doesn't work...
Good luck, Max Xie
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With