Xsl: import and xsl: include in stylesheets do not work in Google Chrome

I am creating a website that uses xsl stylesheets, and I am creating a small library of useful features in the util stylesheet that other sheets import using

<xsl:import href="util" />

at the top of each sheet. This does not work in Google Chrome since it does not yet support xsl: import. Can someone please write me a stylesheet that I can run on the server side, which will read the xsl: import import line and import the corresponding stylesheet before sending it to the client?

+5
source share
4 answers

- , , Chrome. , xsl:import .

  • xsl:import xsl:include ( xsl:include, )
  • , ,
  • ( ). Chrome , .
<xsl:template match="node()">
    <xsl:copy>
       <xsl:copy-of select="@*"/>
       <xsl:apply-templates select="node()"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="xsl:include">
   <!-- you'll probably want to be a bit more restrictive here -->
   <xsl:copy-of select="document(@href)/xsl:stylesheet/*" />
</xsl:template>

: : Chrome Safari.

+5

Python libxml2 libxslt... , - :

import libxml2, libxslt

styledoc = libxml2.parseFile("page.xsl")
style = libxslt.parseStylesheetDoc(styledoc)
doc = libxml2.parseFile("somefile.xml")
result = style.applyStylesheet(doc, None)

.

+2

- php:

<?php
$sXml  = "<xml>";
$sXml .= "<testtag>hello tester</testtag>";
$sXml .= "</xml>";

# LOAD XML FILE
$XML = new DOMDocument();
$XML->loadXML( $sXml );

# START XSLT
$xslt = new XSLTProcessor();
$XSL = new DOMDocument();
$XSL->load( 'xsl/index.xsl', LIBXML_NOCDATA);
$xslt->importStylesheet( $XSL );
#PRINT
print $xslt->transformToXML( $XML );
?>

+1

http://www.w3.org/TR/xslt#literal-result-element , duplicate-xsl-namespace XSL, XSL XSL <xsl:import>.

, , <xsl:import> <xsl:include>.

0

All Articles