This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hello, I am converting XML data into csv format. When I do this I need to add a counter to each of the addresses lines of a client (One client may contain more than one address). Is there a way I can call a template name with a counter where by each call will be initiated with (counter + 1)? Thanks Suresh
Andy Bowes
Ranch Hand
Joined: Jan 14, 2003
Posts: 171
posted
0
If each address line his held as a child element of client i.e. <client> <address></address> <address></address> <address></address> <address></address> </client> then you can just use the position() function to get a sequential number.
HTH
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Suresh Kanagalingam
Ranch Hand
Joined: Aug 17, 2001
Posts: 82
posted
0
Hi Andy, I need to do bit different. If I use your example and assuming that I have 2 addresses for a client, the XML will look like following: <client> <address>Street1</address> <address>City1</address> <address>Prov1</address> <address>PC1</address> </client> <client> <address>Street2</address> <address>City2</address> <address>Prov2</address> <address>PC2</address> </client> I need to translate this to Street1|City1|Prov1|PC1|1 Street2|City2|Prov2|PC2|2 Thanks Suresh
Sree Reddy
Greenhorn
Joined: Dec 20, 2002
Posts: 13
posted
0
Hi, You can get the count in the following way... <xsl:value-of select="count(preceding-sibling::*) + number(1)" /> Basically, all the <Client> tags belogs to same parent. So we are using the sibling concept here. -- Sree