I want to use the function math:random() of EXSLT but I can't make it work. This is my test, the file xslt:
<xsl:stylesheet xmlns:math="http://exslt.org/math" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" extension-element-prefixes="math">
<xsl:import href="math.xsl"/>
<xsl:template match="/">
<xsl:value-of select="(floor(math:random()*10) mod 10) + 1"/>
</xsl:template>
</xsl:stylesheet>
and this is the simple file xml:
<?xml-stylesheet type="text/xsl" href="stile.xslt"?>
<radice>
ciao!
</radice>
This example should not print me "ciao!" and a random number from 1 to 10? Thanks at all for the help.
According to the EXSLT - math:random() documentation, the function is supported by the following XSLT processors: 4XSLT, libxslt, msxsl. What XSLT processor are you using?
According to this page, the default for ExistDB is Xalan, which is not one of the listed processors. (However, according to Xalan's documentation, it does provide math:random()
.)
If you haven't configured a different processor, that would be a good thing to try. My personal recommendation is Saxon. According to its documentation, it supports EXSLT math:random()
.
However, it sounds to me like your XSLT processor may not be getting invoked at all. Can you show us how you're telling ExistDB to run your stylesheet? Have you gotten it to run any stylesheets at all?