Re: [xsl] Retaining value of a Global variable

Subject: Re: [xsl] Retaining value of a Global variable
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Mon, 19 Jul 2004 14:20:19 -0600
Hi Vivek,

Looking at your sample code has lead me to draw the conclusion that the best way to help you understand both what your problem is and the best way in which to solve it is to point you towards an XSLT tutorial that will help you learn the underlying foundation of XSLT first before trying to tackle an advance grouping problem such as this one. It seems Dr. Kay has gone ahead and created some code that will solve your problem. As such I would do two things at this point.... stop whatever you are doing and locate and print out a copy of Wendell's (Piez) email from last week that discussed in detail the concepts and methodology behind your problem and explained them in an easy to understand format that very few people have the capability of doing. Then pay a visit to Dave Pawson's site ( and go to the "Where to Start" section ( and spend some time really trying to build a strong foundation in beginning to intermediate XSLT concepts. Bookmark DaveP's site as this will be a great reference that you will find yourself utilizing a ton just like most of the rest of us do. Next stop is Jeni Tennison's site that David Carlisle pointed you at this morning ( This site will help you tremendously in really bringing home the more advanced topics such as positional grouping (the problem you are currently tackling).

Probably the best thing you can do for now and for the future is to purchase a copy of Dr. Kays XSLT Reference from Amazon ( Jeni also lists several of her titles (although it seems to me there are more titles either out or on there way out than she has listed on her site... but no doubt she knows better than I do :) Maybes she's listing the ones that she feels are best associated with the tutorials on the site and as such I would also invest into one if not all of her XSLT titles as you will find that she has a very gifted (and extremely educated/experienced as does Dr. Kay:) way of teaching XSLT that will ensure a long term retention for the simple fact that when you are finished reading one of her tutorials you will not just know how but you will also understand why, a crucial element of truly understanding XSLT from the foundation on up. Between Wendell's email from last week (he has a GREAT web site as well that showcases and annotates a complete XSLT based application ( and DaveP's and Dr. Tennison's web sites, Dr. Kay's technology and language reference and Dr. Tennison's tutorial and reference styled titles you will be well equipped to be the one answering instead of asking the questions of other newcomers who are trying to get a grasp of XSLT by jumping with both feet from the high dive into the deep end of the XML/XSLT pool and kicking and paddling there way to safety via shear will power and guts. I commend you for being fearless but implore you now to spend some time with the master instructors in a more shallow section of the pool until such time as you are able to do more than tread water until someone comes along to pull you to safety.

Best of luck Vivek!


----- Original Message ----- From: "Vivek Shinde" <Vivek.Shinde@xxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Monday, July 19, 2004 12:01 PM
Subject: RE: [xsl] Retaining value of a Global variable

I'll post it soon. I am trying to find simpler solution. Michael had suggested position() but since I may have the article(s) at any position, that would not work. I am trying with xsl:key.

My main problem is:
I have an XML that contains multiple articles for a newsletter. There could or could not be some articles with article-classification as 'Webcasts'. If I find even a single article with classification of 'Webcast', then I want to print a title 'Webcasts' and then list all the articles. I have done the code for listing the articles. The problem I am having is identifying if there's even one article of that classification and then print 'Webcast' title only once. That's why I was looking to set the global variable and then increment it once I hit the first webcast article and then go for listing the articles of that type. But it seems that's not possible. Therefore I am trying xsl:key. Any other input on doing it simpler way?

The XML sample:
  <teaser>BBBBBBBBBB </teaser>
  <teaser>CCCCCCCCCCC </teaser>
  <teaser>DDDDDDDD </teaser>


-----Original Message-----
From: Wendell Piez [mailto:wapiez@xxxxxxxxxxxxxxxx]
Sent: Monday, July 19, 2004 11:05 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Retaining value of a Global variable

I'm going to leave this one aside for a bit. Until we hear again from Vivek, it's not clear to me that this is -- quite -- a standard grouping problem, due to the requirement to group according to string containment, not just string equality.

It'd be much easier if we could see a representative example of the input.
Vivek, could you post a bit of it, along with a restatement of what kind of
output you want for your input? That way it's all in one email -- less to
guess, less confusing to track.

On the other hand, maybe our haphazard comments and hints have been enough
to help Vivek find the solution on his own.


At 10:32 AM 7/19/2004, M.David wrote:
After being "woken up" to a fresh breath of "oh my goodness did I
swing and miss before the ball even crossed the plate"....

Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.
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