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

Re: How to do this without updating a variable?

Subject: Re: How to do this without updating a variable?
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 07 Sep 2005 19:00:46 -0400
301 direct
Anupam,

At 06:20 PM 9/7/2005, Jay wrote:
Here's one way:
...
            <td><xsl:value-of select="."/></td><td><xsl:value-of
select="sum(preceding::reg/@count) + 1"/></td><td><xsl:value-of
select="sum(preceding::reg/@count) + @count"/></td>

Note that Jay's solution works completely differently from your stated expectation. He is simply traversing the preceding:: axis to collect all reg/@counts appearing before the current one, in order to calculate what its start and end values should be.


That is, where you suggest

So basically output of any node <reg> is based on all the <reg> nodes that
have been processed before it.

Jay silently amends this to read "[the] output of any node <reg> is based on all the <reg> nodes that *appear* before it".


Notice that this restates the problem in a way that has no dependency on processing order, but instead refers simply and solely to the organization of the input.

This is the XSLT way of doing things. Focus on what has to be done and let the processor figure out how to do it.

This can take some getting used to if you are accustomed to managing the flow of control yourself (as you must with procedural languages). But it allows many advantages (including allowing processors to optimize for speed and efficiency in various ways). And once you're used to thinking this way, you may even find it easier (some of us think much easier), because the processor does so much of the work for you.

Cheers,
Wendell


====================================================================== 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 ======================================================================

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.