Xalan-J xsl test cases for xpath 3.1 function fn:random-number-generator, questions

Mukul Gandhi <[email protected]>
Newsgroups gmane.text.xml.xalan.devel
Message-ID <CABuuzNOczZiDuC1bJqNGc3Mb+2oXp6QzT5y9k4J7jRKHzrFaJw@mail.gmail.com>
Hi all,
   I've few questions as follows.

There was a commit to Xalan-J's XSLT 3.0 development branch few
minutes ago, for an implementation of XPath 3.1 function
fn:random-number-generator.

I wish to write an XSL 3 test case for that, on Xalan-J's XSLT 3.0
development branch.

I have following two XSLT stylesheets for this, along with the
mentioned XSL stylesheet transformation results.

1)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         xmlns:xs="http://www.w3.org/2001/XMLSchema"
                         xmlns:fn0="http://fn0"
                         exclude-result-prefixes="xs fn0"
                         version="3.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="/">
       <result>
             <xsl:variable name="rngFunc"
select="random-number-generator()" as="map(xs:string, item())"/>
             <one><xsl:value-of select="$rngFunc?number"/></one>
             <two><xsl:value-of select="let $fn1 := $rngFunc?next,
$fn2 := $fn1() return $fn2?number"/></two>
             <three><xsl:value-of select="let $fn1 := $rngFunc?permute
return $fn1((1,2,3,4,5,6,7))"/></three>
       </result>
   </xsl:template>

</xsl:stylesheet>

XSL transformation result:

<?xml version="1.0" encoding="UTF-8"?><result>
    <one>0.6085228890023606</one>
    <two>0.0834059172050203</two>
    <three>2 3 1 6 4 5 7</three>
</result>

2)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                         xmlns:xs="http://www.w3.org/2001/XMLSchema"
                         xmlns:fn0="http://fn0"
                         exclude-result-prefixes="xs fn0"
                         version="3.0">

   <xsl:output method="xml" indent="yes"/>

   <xsl:template match="/">
      <result>
           <xsl:variable name="rngFunc"
select="random-number-generator()" as="map(xs:string, item())"/>
           <number><xsl:value-of select="$rngFunc?number"/></number>
           <xsl:variable name="seq1" select="(1,2,3,4,5,6,7)" as="xs:integer*"/>
           <sequence><xsl:value-of select="let $fn1 :=
$rngFunc?permute return $fn1($seq1)"/></sequence>
           <xsl:for-each select="1 to 3">
                 <number_and_sequence id="{.}">
                      <number><xsl:value-of select="let $fn1 :=
$rngFunc?next, $fn2 := $fn1() return $fn2?number"/></number>
                      <sequence><xsl:value-of select="let $fn1 :=
$rngFunc?permute return $fn1($seq1)"/></sequence>
                 </number_and_sequence>
           </xsl:for-each>
      </result>
   </xsl:template>

</xsl:stylesheet>

XSL transformation result:

<?xml version="1.0" encoding="UTF-8"?><result>
  <number>0.6098714393771809</number>
  <sequence>7 5 2 3 6 1 4</sequence>
  <number_and_sequence id="1">
       <number>0.0657944709157764</number>
       <sequence>3 7 4 1 2 6 5</sequence>
  </number_and_sequence>
  <number_and_sequence id="2">
       <number>0.2284167574420906</number>
       <sequence>1 6 2 3 4 7 5</sequence>
  </number_and_sequence>
  <number_and_sequence id="3">
       <number>0.7263336140028495</number>
       <sequence>5 7 3 6 2 4 1</sequence>
  </number_and_sequence>
</result>

How can we write JUnit test cases for these mentioned XSL
transformation stylesheets, since these XSL transformation results
produce numeric random values and permutations?

Thanks in advance for any answers.


-- 
Regards,
Mukul Gandhi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.