xsl-list
[Top] [All Lists]

Re: [xsl] shuffling words in text content

2021-09-07 16:31:36
Hi everyone,

I replaced the reordering variable definition with the following:

    <!-- perturb the word order -->
    <xsl:variable name="shuffled-words" as="xs:string*">
      <xsl:sequence select="random-number-generator()?permute($words)"/>
    </xsl:variable>

and ran the transformation in Oxygen, and it works great!

I think the current implementation is good, but not great. There are two 
limitations to my approach.


Limitation 1: Words are shuffled within each text() element, but not across 
them. This doesn't scramble at all:

<p>Use <code>true</code> and <code>false</code> carefully.</p>

I think this would be a really, really hard problem to solve, especially for 
arbitrarily nested element content like multi-level lists or CALS tables.


Limitation 2: random-number-generator() is deterministic within a given run 
(and is documented as such). Within a run, each of these lines is scrambled in 
the same order:

<p>a b c</p>
<p>A B C</p>
<p>x y z</p>
<p>X Y Z</p>

I think I could solve this by somehow setting the seed value to the result of 
generate-id() each time, but I haven't figured out the mechanics of that yet.

 - Chris
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--


<Prev in Thread] Current Thread [Next in Thread>