Return-Path: Mailing-List: contact cocoon-users-help@xml.apache.org; run by ezmlm Delivered-To: mailing list cocoon-users@xml.apache.org Received: (qmail 98767 invoked from network); 22 Dec 2000 13:10:14 -0000 Received: from latinia252.adam.es (HELO mail.latinia.com) (root@195.77.29.252) by locus.apache.org with SMTP; 22 Dec 2000 13:10:14 -0000 Received: from io ([195.77.29.242]) by mail.latinia.com (8.11.0/8.11.0) with SMTP id eBMDDp105260 for ; Fri, 22 Dec 2000 14:13:51 +0100 Message-ID: <005001c06c18$2d7aa080$2653a8c0@latinia.com> From: "Ivan" To: Subject: Random selection from XML applying XSL with JS function Date: Fri, 22 Dec 2000 14:07:46 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_004D_01C06C20.8F2517E0" X-Priority: 1 X-MSMail-Priority: High X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N ------=_NextPart_000_004D_01C06C20.8F2517E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all! I want to get a random output from an xml file applying an XSL, but don't know how to call the Javascript function to get the random number appear. Any help would be welcomed. XML Data File (brands.xml) BMW Mercedes Opel Porsche Ferrari Renault Citro=EBn Seat VolksWagen Audi Saab Toyota Nissan Subaru Lamborghini _____________________________________________________ XSL to output random flower (brands.xsl) type=3D"text/html"=20 Random There are car brands in the = list.



Selected car brand number is:
_____________________________________________________ Resulting HTML Output There are 15 car brands in the list. BMW Mercedes Opel Porsche Ferrari Renault Citro=EBn Seat VolksWagen Audi Saab Toyota Nissan Subaru Lamborghini Selected car brand number is: _____________________________________________________ Then I wold like to get the string in xml file that is equal to the number of this selection, but don't know how to do it as well Anyway to do this for XSL instead of Javascript function?=BF Thanks very much in advance for any help that could point me in the right way. Ivan ------=_NextPart_000_004D_01C06C20.8F2517E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi all!
 
I want to get a random output from an = xml file=20 applying an XSL,
but don't know how to call the = Javascript=20 function to get the random
number appear. Any help would be=20 welcomed.

XML Data File (brands.xml)

<?xml version=3D"1.0" encoding=3D"iso-8859-1"?>
<?xml-stylesheet type=3D"text/xsl" = href=3D"brands.xsl"?>
<?cocoon-process type=3D"xslt"?>
<brands>
<car>BMW</car>
<car>Mercedes</car>
<car>Opel</car>
<car>Porsche</car>
<car>Ferrari</car>
<car>Renault</car>
<car>Citro=EBn</car>
<car>Seat</car>
<car>VolksWagen</car>
<car>Audi</car>
<car>Saab</car>
<car>Toyota</car>
<car>Nissan</car>
<car>Subaru</car>
<car>Lamborghini</car>
</brands>

_____________________________________________________

XSL to output random flower (brands.xsl)

<?xml version=3D"1.0" encoding=3D"iso-8859-1" = ?>
<xsl:stylesheet version=3D"1.0" xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform">
<script language=3D"javascript">
function getRandom(){
return (Math.round(Math.random()*(count(car)))
}
</script>
<xsl:template match=3D"brands">
<xsl:processing-instruction=20 name=3D"cocoon-format">type=3D"text/html"</xsl:processing-instruction>
<html>
<head>
<title>Random</title>
</head>
<body>
There are <xsl:value-of = select=3D"count(car)" = /> car = brands in the=20 list.<br /><br />
<xsl:for-each = select=3D"car">
<xsl:apply-templates = select=3D"." = />
<br />
</xsl:for-each>
<br />
<xsl:param = name=3D"selectedCar" = select=3D"getRandom()"/>
Selected car brand number is:<xsl:copy-of select=3D"$selectedCar"/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

_____________________________________________________

Resulting HTML Output

There are 15 car brands in the=20 list.

BMW
Mercedes
Opel
Porsche
Ferrari
Renault
= Citro=EBn
Seat
VolksWagen
Audi
Saab
Toyota
Nissan
Su= baru
Lamborghini

Selected=20 car brand number is:
<number_of_random_selection>
 
_____________________________________________________
 
Then I wold like to get the string in = xml file that=20 is equal to the
number of this selection, but don't = know how to do=20 it as well
 
Anyway to do this for XSL instead of = Javascript=20 function?=BF
 
Thanks very much in advance for any = help that=20 could point me
in the right way.
 
Ivan
------=_NextPart_000_004D_01C06C20.8F2517E0--