Re: [xsl] unique-sequence-numbering

Subject: Re: [xsl] unique-sequence-numbering
From: Jeff Kenton <jkenton@xxxxxxxxxxxxx>
Date: Wed, 7 Aug 2002 08:53:45 -0400 (EDT)

Short of an elegant solution, here's a simple way to do it:

Step 1: go through your XML file and create another with the student 
elements duplicated as necessary.

Step 2: go through the new file and create the output -- sequence 
numbering is now trivial.


On Wed, 7 Aug 2002 subbu@xxxxxxxxxxxx wrote:

..Sorry for reposting..The subject was wrong!!
..i have an xml file which looks like below.
..<?xml version="1.0"?>
..<students>
..	<student id = "101">
..		<name>A</name>
..		<address>XXX</address>
..	</student>
..	<student id = "201">
..		<name>B</name>
..		<address>YYY</address>
..	</student>
..	<student id = "301">
..		<name>C</name>
..		<address>XXX</address>
..	</student>
..	<student id = "401">
..		<name>E</name>
..		<address>YYY<address>
..	</student>
..</students>
..
..And i have to deliver a CSV file that has the following fields.
..
..Student-id , SequenceNumber , name, address.
..
..Sequence number is an automatically generated  number ( should start from 1 to 
..end of Students )..
..
..so a typical CSV FIle would be..
..
..101,1,A,abc
..102,2,B,bcd
..103,3,C,cde
..104,4,D,efg
....
..Now There is a business rule that says that if a student has an address value 
..that is equal to 'YYY',  then show the complete information *line* twice, with 
..only the sequence number changed..
..That is
..101,1,A,abc
..102,2,B,bcd
..102,3,B,bcd  <-- repeated again with sequence number changed
..103,4,C,cde
..104,5,D,efg
..104,6,D,efg <-- repeated again with sequence number changed
..
..
..I am using the position() function to get the serial number..This is where the 
..problem starts..
..If i put a condition that
.. if address == 'YYY' ( just pseudo code. dont mind the syntax )
..{
..value-of-select --> @id,position(),name,address
..		  @id,position()+1,name,address
..}
..else
..{
..value-of-select --> @id,position(),name,address
..}
..
..I end up getting something like this
..
..101,1,A,abc
..102,2,B,bcd
..102,3,B,bcd  <-- repeated again with sequence number changed
..103,3,C,cde  <-- same sequence number repeated... That is the position ..
..104,4,D,efg
..104,5,D,efg <-- repeated again with sequence number changed
..
..and what i want should look like
..
..101,1,A,abc
..102,2,B,bcd
..102,3,B,bcd  <-- repeated again with sequence number changed
..103,4,C,cde  <-- this is not showing up position but prev-seq+1
..104,5,D,efg
..104,6,D,efg <-- repeated again with sequence number changed
..
..so the requirement tells, if you find address equal to 'YYY', then add it show 
..it once more with a sequence number -> prev-seq-num +1  and then every 
..subsequent sequence number should be consequitive. The sequence number is a 
..unique number ( from 1 to End of students ).
..
..I can not think of a way to do this.This looks totally like a dead end to me.
..I shall be highly thankful if some one can please help me out of this 
..situation...
..Please let me know if i am missing out any information that would make the 
..question clearer..
..
..Thanks a ton!!!!!!!!! 
..
..--------------------------------------------------------------
..Sent with "Me-Mail", Boltblue's FREE mobile messaging service.
..http://www.boltblue.com
..
..
.. XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
..

-- 

Jeff Kenton
DataPower Technology, Inc.
 *** Wire Speed XSLT ***

http://www.datapower.com/products.shtml



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread