[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: increment value - philosophy
Hello Ken, Thanks for your note. That put things into the right perspective. Yes, you are true that we are trying to get too much out of XSL. My problem is due to two nested loops and the position() value is different in these two loops. I have started looking into recursive template implementation to find a solution to my problem there. If you have any sample for that, it will definitely be helpful to start with. Thanks for your note. Anoop -----Original Message----- From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx] Sent: Thursday, January 22, 2004 1:46 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: RE: increment value - philosophy At 2004-01-22 13:09 -0500, Govil, Anoop (Contractor) wrote: > >From what I understand, your problem seems to be same as mine: Please check >my posting today: Linear counting problem in nested loop. > >I guess you have a nested loop within a loop (just like I have and you need >to set the ids as a linear counter value). I am in the same boat if I >understood you right. Yes, you are both in the boat of thinking "counters". My students come in to my courses with the same misconception about XSLT. When you try to treat XSLT like a programming language, you end up going through terrible contortions with ugly and poorly performing stylesheets. The "nature of writing XSLT stylesheets" parallels the "nature of working with hierarchies" and the node tree from an XML document is a hierarchy. Think of your problems as examinations of the hierarchy, and try to abandon classical programming techniques as they do not apply. If you need something unique about a node, consider "where is it in the hierarchy?" If it is globally unique when unique amongst its siblings, or unique in the selection of nodes in the select expression, you can probably use position() or a simple count(). If it is not globally unique when examined amongst its siblings, consider its ancestry and what components of the ancestry you can use for uniqueness. Remember that every time you process a new node, you are in a new context that is distinct from the context of all other source tree nodes ... what can you do with that node that is different? Consider chapter counting: the classical programming technique is to set a variable and increment it. In XSLT you, instead, query the processor and ask "Which source tree chapter node is being processed?" and expose the return value to the result as the output chapter number. The next time around, ask again; don't try to keep it around. The classical programming models have side effects, while XSLT does not. >I hope someone out there (XSL Guru) may be able to solve our issues. Sorry, my car license plate reads "XML Guru", not "XSL Guru" (picture in my web site bio and entry in the Internet License Plate Gallery), but hopefully this commentary above still helps. ...................... Ken p.s. BTW, it happens that XSLT *is* Turing Complete, but it is a functional programming language without side effects and you have to treat it that way. -- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Breast Cancer Awareness http://www.CraneSoftwrights.com/s/bc XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
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
|