1

This is my XML document:

<?xml version="1.0"?>
<?xml-stylesheet type='text/xml' href='/foo.xsl'?>
<document/>

This is /foo.xsl:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:foo="foo"
  version="2.0" exclude-result-prefixes="xs">
  <xsl:function name="foo:const" as="xs:string">
    <xsl:text>ABC</xsl:text>
  </xsl:function>
  <xsl:template match="/">
    <xsl:value-of select="foo:const()"/>
  </xsl:template>
</xsl:stylesheet>

Works fine with Saxon 8.7 and produces ABC, as an output. But in Safari and in Chrome this document doesn't work (just an empty page with no error messages). What is it about? Safari and Chrome don't support XSL functions?

yegor256
  • 102,010
  • 123
  • 446
  • 597

2 Answers2

4

Sadly, none of the browsers yet support XSLT 2.0 natively. I think they're all waiting for the others to move first.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
1

Have you tried using SaxonCE?

This is Saxon 9.x implemented in Javascript -- it is reported to work with any of the five major browsers.

At the last Balisage conference Michael Kay (@Michael Kay ) demoed this working on his iPhone.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
Dimitre Novatchev
  • 240,661
  • 26
  • 293
  • 431
  • Very interesting link, thanks. Now it's a question of performance: who will do the transformation faster - Saxon on the server or SaxonCE inside the browser.. – yegor256 Nov 17 '11 at 07:40
  • Of course @Michael Kay is the developer of Saxon and he can best answer such a question. I am not sure that there is a compelling argument in favor of either way. Javascript processing may be a tad slower, but happens on your box and thus network latency + server overload are eliminated. – Dimitre Novatchev Nov 17 '11 at 13:18
  • The two architectures are just so different that you can't compare them on a single metric. Offloading work from the server to the client should certainly help server throughput, but whether it improves latency depends on how busy the server is. One of the performance issues with Saxon-CE is the delay when it's first downloaded to the browser (900Kb), especially on a slow connection; after that it's cached and very fast. – Michael Kay Nov 18 '11 at 23:00