I'm building a website that uses xsl stylesheets, and I'm building up a small library of useful functions in a util stylesheet that other sheets import with
<xsl:import href="util" />
at the top of every sheet. This doesn't work in Google Chrome, as it doesn't support xsl:import yet. Can someone please write me a stylesheet that I can run on the server side that will read the xsl:import line and import the relevant stylesheet before its sent to the client?
http://www.w3.org/TR/xslt#literal-result-element shows how to solve the duplicate-xsl-namespace issue when writing an XSL stylesheet which transforms your existing XSL stylesheet into an XSL stylesheet with the
<xsl:import>
s expanded.Be careful, though, about the difference between
<xsl:import>
and<xsl:include>
.Try something like this in php:
I'd do something like the following, which will combine the stylesheet serverside, before it gets to Chrome. The first step is in place because
xsl:import
is not the same as replacing all places with the imported stylesheets.xsl:import
withxsl:include
(import priority isn't applicable toxsl:include
, so you may need to change your code and use priorities instead)Update: Just a note: the Chrome bug appears in Safari too.
You could do it in Python with the libxml2 and libxslt modules... not to do all your work for you, but starting with something like this:
Then just serve the thing back out.