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

creating arbitrary document references

Subject: creating arbitrary document references
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 May 2019 20:37:47 -0000
 creating arbitrary document references
Hello --

I'm using XSLT 3.0 in oXygen 21.1.

I have a directory structure of test documents generated by oXygen from
(specialized) DITA XSD schemas.

The schema generation process creates attribute cross reference
attribute values; these do not resolve to an actual file.  If I want the
cross reference values to validate fully by oXygen DITA validation,
the attribute value has to contain some actual file name or
resolvable path.

Using the recursive form of the EXPath function file:list() will get me
all the documents in the test document directory structure.  So
presumably what I want to do is to permute the list of document
locations into some random order using the permute form of
random-number-generator() and then cycle through that list replacing
each cross reference as I come to it with the next item in the list.

Only of course that doesn't work at all; that's the mutable variable
solution. Stuff the permuted list on to a global stack at the start, and
then pop the stack as a value is wanted.  (And if the stack runs out,
shove the permuted sequence on to it again.)

A random number solution,
<xsl:variable name="pick" 
    select="(((random-number-generator(current-dateTime())('number') * $range) mod $range) + 1) => xs:integer()"/>

and then using $docNameSequence[$pick] to get a document name to
reference gives me the same result each time.  Reading the specification
for random-number-generator() leaves me thinking that this is the
correct behaviour.

I care that the references are different, but not that they're in some
order.  So the "I don't know in what order the template is going to
match various xref/@href nodes" isn't important.  And it's not at all
hard to get the sequence of file references available in the directory
structure of test documents.  I absolutely do not know that I have more
files to reference than references to files, or the other way around;
any useful solution needs to cope gracefully with either case.

So how can I pick a random member of that sequence of
files-available-to-be-referenced each time the template matches and I
need to replace the value of @href with that arbitrary actual file


Current Thread


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.
First Name
Last Name
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.