I create an XSLT with Altova, now I want to use it with Basex and call the transformation from java. In Altova I don't have any problem, but under Basex I have "[FODC0002] Impossible to compile the stylesheet". A part of the XSLT is:
<xsl:stylesheet version='1.0' xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:js="urn:custom-javascript" exclude-result-prefixes="msxsl js" xmlns:math="http://exslt.org/math" extension-element-prefixes="math">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:template match="Linee">
<root_bordero>
<xsl:element name="bordero">
<xsl:apply-templates select="Linea"/>
</xsl:element>
</root_bordero>
</xsl:template>
<xsl:template match="Linea">
<xsl:variable name="num_corse_mattina" select="count(./Fasce[./@nome='mattina']/orari_partenza/*)"/>
<xsl:variable name="num_bus" as="xs:integer" select="count(document('/path_to/Autobus.xml')/Autobus/Autobus[./@Linea=current()/@id_linea and ./@Fascia='mattina']/@Targa)"/>
.....
<xsl:variable name="array_bus_mat" as="xs:string*" select="tokenize(js:random(number($num_bus),number($num_corse_mattina)),'\s')"/>
......
</xsl:template>
<msxsl:script language="JavaScript" implements-prefix="js">
<![CDATA[
function random(range,lenght) {
var array = new Array(lenght);
var array_key = new Array(lenght);
var min = 1;
for (var i = 0; i < lenght; i++) {
array[i]=i+1;
}
array_key[0] = Math.floor(Math.random() * (range - min +1))+min;
for (var i=1; i<lenght; i++) {
var key = Math.floor(Math.random() * (range - min +1))+min;
while(array_key[i-1]==key){
key = Math.floor(Math.random() * (range - min +1))+min;
}
array_key[i]=key;
}
var string='';
for (var i=0; i<lenght-1; i++) {
string=''+string+array_key[i] + ' ';
}
string=string+array_key[i];
return string;
}
]]>
</msxsl:script>
</xsl:stylesheet>
Under Java, I tried the XSLT transformation using both JAXP and Basex JQX, but the compile error is "The first argument of not static Java function 'random' is not a valid object reference. "
Please, help me!!!