[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Grouping and filtering

Subject: Re: Grouping and filtering
From: subbu@xxxxxxxxxxxx
Date: Wed, 07 Aug 2002 12:44:19 +0100
yyy.102
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.