|
Subject: Re: [xsl] Grouping and filtering From: subbu@xxxxxxxxxxxx Date: Wed, 07 Aug 2002 12:44:19 +0100 |
Hello People, I am stuck up with a problem..
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,XXX
102,2,B,YYY
103,3,C,XXX
104,4,D,YYY
..
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,XXX
102,2,B,YYY
102,3,B,YYY<-- repeated again with sequence number changed
103,4,C,XXX
104,5,D,YYY
104,6,D,YYY<-- 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,XXX
102,2,B,YYY
102,3,B,YYY<-- repeated again with sequence number changed
103,3,C,XXX<-- same sequence number repeated... That is the position ..
104,4,D,YYY
104,5,D,YYY<-- repeated again with sequence number changed
and what i want should look like
101,1,A,XXX
102,2,B,YYY
102,3,B,YYY<-- repeated again with sequence number changed
103,4,C,XXX
104,5,D,YYY
104,6,D,YYY<-- 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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Re: [xsl] Attribute repeated ho, Thomas B. Passin | Thread | [xsl] Urgent: help using fop in ser, tpass001 |
| [xsl] Attribute repeated how to avo, alex ek | Date | Re: [xsl] Attribute repeated how to, Joerg Heinicke |
| Month |