[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: shuffling words in text content

Subject: Re: shuffling words in text content
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 7 Sep 2021 21:31:30 -0000
Re:  shuffling words in text content
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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.