|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: test for even or odd
Dear "xsl list", whoever-you-are,
You check oddness or evenness generally the same way you do in the particular case of alternating colors. If $count is your count of nodes, then test="$count mod 2 = 1" returns true for odd counts (when count is divided by 2, the remainder is 1) test="$count mod 2 = 0" returns true for even counts (when it's divided by 2 the remainder is 0) Because of the number->Boolean casting rules (1 = true, 0 = false), if you say test="$count mod 2" it will test true for odd counts, false for even counts. As Mike showed earlier today, the modulus operator (which returns remainders) can be used like this to determine any kind of regular cycling, not just odd-even. Enjoy, Wendell At 05:47 PM 1/21/2005, you wrote: So I have come down to this, I am going to get a count of how many elements there are of a certain tag. How can I test if the number is even or odd? Stateing the obvious here but if it came back with 3 of the tag I would want a "this number is odd" returned (or 1 and 0 for even). ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








