Alex Rivera | Logout

Can Chrome be made to perform an XSL transform on a local file?

Asked 2010-09-30T08:17:00.040
102

I was looking into xslt and started testing with the examples on w3schools.

However, when I save the xml and xsl in files and try opening them locally, chrome won't perform the xsl transform. It just shows a blank page.

I have added the<?xml-stylesheet type="text/xsl" href="style.xsl"> tag to the xml document, and firefox renders it as it is supposed to look. Also, if I look at the files through a web server, chrome displays the file as it is supposed to look.

Is it that chrome has a problem finding the stylesheet information when the link is local? Changing the href to file:///C:/xsl/style.xsl didn't make any difference.

Update: This seems to be a side effect of a security-policy to not treat file:///* as same origin. This makes the following error appear in the console:

Unsafe attempt to load URL file:///C:/xsl-rpg/style.xsl from frame with URL file:///C:/xsl-rpg/data.xml. Domains, protocols and ports must match.

Edit
Report

1 Answer

66

You can do this locally by running Chrome with --allow-file-access-from-files flag.

On OS X, from Terminal app run:
/Applications/Google\ Chrome.app/contents/MacOS/Google\ Chrome --allow-file-access-from-files

On Windows: from the command prompt run:
path\to\your\chrome\chrome.exe --allow-file-access-from-files

Note: You will probably have to quit Chrome if it is currently running.

answered 2013-04-14T14:06:20.003

Your Answer