1

Can someone tell my why the following use of fn:max does not work?

XML document:

<?xml version="1.0" encoding="UTF-8"?>
<a>
<b>1</b>
<b>2</b>
<b>3</b>
</a>

XSLT stylesheet:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
       <p><xsl:value-of select="count(a/b)"/></p>
       <p><xsl:value-of select="max(a/b)"/></p>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>

The call to count() returns the correct result, but every XSLT engine that I have used (namely Firefox and Apache FOP) reject the call to max(), even though Apache says that FOP supports it.

What am I doing wrong?

kjhughes
  • 106,133
  • 27
  • 181
  • 240
Dan R.
  • 761
  • 5
  • 21

1 Answers1

2

Because max() requires XSLT / XPath 2.0, and your processors only support XSLT / XPath 1.0:

  • Firefox (and all browsers) only support XSLT 1.0.
  • Apache FOP isn't an XSLT processor; it's an XSL-FO processor. You might generate XSL-FO via XSLT 1.0 or 2.0, but the table you cited lists functions that you might include in the XSL-FO, not functions that you can include in your XSLT.

Note that your XSLT is generating HTML, not XSL-FO.

See also

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • If you're using Apache FOP then you're in the Java world, so it's easy to switch to Saxon to get XSLT 2.0 (and 3.0) functionality. On the browser, you have the option to use Saxon-JS which also supports XSLT 3.0. – Michael Kay Jul 24 '18 at 06:33