Re: [xsl] Upon matching attribute value, increment output

Subject: Re: [xsl] Upon matching attribute value, increment output
From: "M. David Peterson" <m.david@xxxxxxxxxx>
Date: Thu, 23 Sep 2004 23:37:31 -0700
The first thing you would need to do is take away the @ symbol from each attribute in your source XML. You use the @ symbol to reference attributes of a specified element from within XSLT but its a symbolic, not literal representation.

Youre then going to want to head over to to Jeni Tennisons site and spend some time with one of her fantastic tutorials on grouping... http://www.jenitennison.com/xslt/grouping/index.html.

I would also add Dave Pawson's XSL-List FAQ to your favorites as this will allow you to reference answers to questions from the past regarding the little details that we all face on a day to day basis.

Last, visit your local B&N or go to Amazon and pick up Dr. Michael Kays XSLT Programmers Reference (http://www.amazon.com/exec/obidos/ASIN/0764543814/qid=1096004581/sr=ka-1/ref=pd_ka_1/102-7358038-5586505) . I would personally pick up this linked one first (covering XSLT 1.0, second edition) even though you may find it tempting to get his latest XSLT 2.0 edition (which, if its in your budget, I would pick up as well but then set it aside and read the "old testament" before your try to understand what the "new testament" is all about... sorry for the kind of cheezy comparison. And I dont mean it to sound mocking of the actual Bible either... but as far as XSLT is concerned this is its bible and as such I would suggest starting with the foundation and then moving forward from there).

Please dont take this as being blow off... its not that way at all. These are the three best places to start with; the third acting as the reference that will undoubtedly become your best friend over the coming weeks. There are a ton of people here who will bend over backwards to help you understand XSLT from as many angles as you want to consume. Keep the questions coming but also add these links and this book as your foundation to build from.

Best of luck to you! And, again, don't hesitate to ask for help. Just do your homework and then come prepared and you will find yourself with more help than than you could ever imagine.

Best regards,

<M:D/>

Russ Little wrote:



If I have the following XML:
<GRP>
<CON @CODE="ABC"/>
<CON @CODE="DEF"/>
<CON @CODE="ABC"/>
<CON @CODE="ABC"/>
<CON @CODE="XYZ"/>
<CON @CODE="ABC"/>
</GRP>
And I want my output to be:
ABC
DEF
ABC_1
ABC_2
XYZ
ABC_3
How would I get there? I cannot seem to manage it with any combination of count, value-of, match, etc., and almost all posts I see are for node values instead of attributes, or HTML instead of text...nothing I've seen seems to give me a valid idea to run with.
Any help would be greatly appreciated!
Thanks,
Russ

Current Thread