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

Computed Location Predicate

Subject: Computed Location Predicate
From: "Richard Patchet" <rpatchet@xxxxxxxxxx>
Date: Thu, 2 Jan 2003 08:11:31 -0600
richard patchet
I have a most vexing problem. I am writing a transform to create a
sample document from a schema. For fun, I thought I would randomize the
selection of items from enumerated lists. With Saxon 6.5.2, I tried many
variations of the predicate before final success with the following bit
of the code, which is within a for-each selecting
"/xs:schema/xs:complexType[<pulls the target
complexType>]/xs:restriction".

            <xsl:variable name="elementValue">
                <xsl:choose>
                    <xsl:when test="xs:enumeration">
                        <xsl:variable name="enumPtr">
                            <xsl:value-of
select="string-length($allValues) mod count(xs:enumeration) + 1"/>
                        </xsl:variable>
                        <xsl:value-of
select="xs:enumeration[number($enumPtr)]/@value"/>
                    </xsl:when>
                        .
                        .
                        .
                </xsl:choose>
            </xsl:variable>
            <xsl:value-of select="$elementValue"/>

During the course of debugging, I used the the following without
success:

            <xsl:variable name="elementValue">
                <xsl:choose>
                    <xsl:when test="xs:enumeration">
                        <xsl:value-of
select="xs:enumeration[number(string-length($allValues) mod
count(xs:enumeration) + 1)]/@value"/>
                    </xsl:when>
                        . 
                        .
                        .
                </xsl:choose>
            </xsl:variable>
            <xsl:value-of select="$elementValue"/>

I understand that my problems with (many) earlier versions were due to
the processor's inability to distinguish the predicate as a number
rather than a non-number and therefore a boolean. But why does the
processor differentiate between casting a variable to a number, which
works, and casting an expression to a number, which does not work?

Any suggestions?



Richard Patchet
bTrade, Inc.
2324 Gateway Drive
Irving, TX 75063
972-5802981
www.bTrade.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.