0

for example i have the following xml file :

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="examen.xsl"?>
<examen>
    <question reponse="ID1">
        <enonce>Question 1</enonce>
        <reponse id="ID1">R1</reponse>
        <reponse id="ID2">R2</reponse>
        <reponse id="ID3">R3</reponse>
        <reponse id="ID4">R4</reponse>
    </question>
    <question reponse="ID6">
        <enonce>Question 2</enonce>
        <reponse id="ID5">R1</reponse>
        <reponse id="ID6">R2</reponse>
        <reponse id="ID7">R3</reponse>
        <reponse id="ID8">R4</reponse>
    </question>
    <question reponse="ID10">
        <enonce>Question 3</enonce>
        <reponse id="ID9">R1</reponse>
        <reponse id="ID10">R2</reponse>
        <reponse id="ID11">R3</reponse>
        <reponse id="ID12">R4</reponse>
    </question>
</examen>

and i need to select 5 or more questions randomly using xslt

Thanks for any help ;)

Ahmed Zeini
  • 93
  • 1
  • 7
  • How can you select 5 or more questions from an input of 3 questions only??? In any case, there is no random functionality in XSLT 1.0 or 2.0. See: https://stackoverflow.com/questions/25867727/generate-random-number-in-rss-viewer-webpart/25869149#25869149 – michael.hor257k Feb 18 '22 at 22:05
  • @michael.hor257k nooo the inputs it's more than 3 but i mentioned her only 3, thank you – Ahmed Zeini Feb 18 '22 at 22:10
  • Well, which processor will you be using? You can generate a random number from a seed of current dateTime, if your processor supports that.. – michael.hor257k Feb 18 '22 at 22:24
  • @michael.hor257k now i can generate random number between two numbers by using java.lang.math inside xslt but based on that i cant get randomly questions to now ;( – Ahmed Zeini Feb 18 '22 at 22:28
  • Which XSLT 2 processor do you use? Saxon is the most common and since Saxon 10 and XSLT 3 and higher-order function support it has e.g. `random-number-generator(current-dateTime())?permute(//question)[position() le 5]` so check whether you can't use Saxon HE 10 or 11 or 9.8 or 9.9 for the commercial editions. – Martin Honnen Feb 19 '22 at 00:11

0 Answers0