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

Filtering on a tokenized list

Subject: Filtering on a tokenized list
From: "Rick Quatro rick@xxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Feb 2017 12:48:55 -0000
 Filtering on a tokenized list
Hi All,

I have an attribute value that I want to convert to a sequence of decimals:

@colwidth="0.439in 1.845in"

I am using tokenize to drop the measurement units before I convert each
member to decimal:

tokenize($widths,'[^\.\d]')

This works, except I get a empty string as the last item in the list. I saw
in Michael's book that I can filter out the empty member with a predicate:

tokenize($widths,'[^\.\d]')[.]

I can't quite understand how the predicate [.] works. Is it like saying
"non-empty strings"? Would it be equivalent to 

[not(.="")]

Thank you in advance.

-Rick

By the way, here is my complete function. Any suggestions for improvements
are appreciated. I am going from absolute widths:

0.439in 1.845in

to a sequence of percentages:

19, 81

    <!-- Function for converting absolute table column widths to
proportional (percentage) widths. -->
    <xsl:function name="rq:getProportionalWidths">
        <!-- widths parameter is @colwidth in the form of absolute
dimensions. -->
        <xsl:param name="widths"/>
        <!-- Drop the measurement units and convert the strings to decimals.
-->
        <xsl:variable name="tokens"
select="tokenize($widths,'[^\.\d]')[.]"/>
        <xsl:variable name="decimals" select="for $i in $tokens return
xs:decimal($i)"/>
        <!-- Divide each number by the total of all numbers and multiply by
100. -->
        <xsl:sequence select="for $i in $decimals return round($i div
sum($decimals) * 100)"/>
    </xsl:function>

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.