I'm having an issue when attempting to include and access multiple XML documents in an XSL stylesheet. I'm assigning document nodes as variables and then attempting to access them in my xsl:template, similar to this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:variable name="doc1" select="document('test.xml')" />
<xsl:template match="/">
<div>
<span id="id_total">
<xsl:value-of select="count($doc1//Root)"/>
</span>
</div>
</xsl:template>
</xsl:stylesheet>
I get the correct count when using IE & Firefox, however any WebKit browser (Safari, Chrome) gives me a count of 0. Any thoughts?
Chrome has a cross-origin-policy that prevents includes of local files. The document function can only reference itself locally:
Google have decided that allowing the .xml file to read the .xlst file off a file:// URL is a security hole and they have blocked it.
The chrome.exe command line option --allow-file-access-from-files will circumvent this safeguard.