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

RE: Need help on sorting a dollar amount.

Subject: RE: Need help on sorting a dollar amount.
From: Sreeni Chippada <sreeni@xxxxxxxxx>
Date: Sun, 27 Oct 2002 09:12:52 -0500
list of dollar amounts
Hi,
	Some one on the list has already helped me out. 
	He sent it to me directly.

Here is the XML and the XSL.


	When I try to sort on th MRC, it was not sorted. My guess was
because of the comma in the dollar amount. So I used 
	<xsl:sort select="translate(MRC, ',', '')" data-type="number"
order="ascending"/>

	It did not work, probably because some thing else worng in my
enviromnet. 
	Senthil pointed out that it works for him. Now it works fine for me.

Thanks for you help,
Sreeni


The XML:
*********************
	  <StatementLocations>
		<Locations>
	 	  <Location>
			<LocationName/>
			  <LocationName/>
				<LocationName>Location1</LocationName>
				<LocationAccount>2395693</LocationAccount>
				<MRC>48,002.76 </MRC>
				<NRC>12,686.38 </NRC>
				<Local/>
				<LD/>
				<OCC/>
				<Taxes>8,893.97 </Taxes>
				<LocationAmount>69,583.11</LocationAmount>
		  </Location>
		  <Location>
			<LocationName/>
			 <LocationName/>
			 <LocationName>Location2</LocationName>
			 <LocationAccount>2395691</LocationAccount>
			 <MRC>187,604.40 </MRC>
			 <NRC>39,209.00 </NRC>
			 <Local/>
			 <LD>31.35 </LD>
			 <OCC/>
			 <Taxes>2,239.59 </Taxes>
			 <LocationAmount>229,084.34</LocationAmount>
		  </Location>
              .
		  .
		  .
		</Locations>
	  <StatementLocations>

*************************
The correspondign XSL


	<xsl:template match="StatementLocations">
		<xsl:choose>
			<xsl:when test="$location-sort-mode='name'">
				<xsl:apply-templates
select="Location[./LocationName/text()]">
					<xsl:sort select="LocationName"
data-type="text" order="{$location-sort-order}"/>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:when test="$location-sort-mode='account'">
            <xsl:apply-templates select="Location[./LocationName/text()]">
					<xsl:sort select="LocationAccount"
data-type="number" order="{$location-sort-order}"/>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:when test="$location-sort-mode='mrc'">
				<xsl:apply-templates
select="Location[./LocationName/text()]">
					<xsl:sort select="MRC"
data-type="number" order="ascending"/>
				</xsl:apply-templates>
			</xsl:when>
			<xsl:otherwise>
				<xsl:apply-templates
select="Location[./LocationName/text()]"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

************************************
Expected Result:
Name      Account      MRC     NRC         Taxes      Charges 
Location1 2395690     50.00    200.00         8.80        258.80 
Location2 2395694  8,762.00  2,325.78     1,733.15     12,820.93 
Location3 2395693 48,002.76  12,686.38     8,893.97    69,583.11 
Location4 2395692 65,128.66  10,419.00     10,743.35   86,291.01 
Location5 2395691 187,604.40  39,209.00     2,239.59  229,084.34 

>> -----Original Message-----
>> From: Vasu Chakkera [mailto:vasucv@xxxxxxxxxxx]
>> Sent: Sunday, October 27, 2002 8:07 AM
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject: Re:  Need help on sorting a dollar amount.
>> 
>> 
>> You have to be a little more elaborative about your problem.
>> do the following.
>> 1. Give an example of your XML file.
>> 2. Give an example of what you would expect out of the transformation
>> 3. Show us what you are getting.
>> 
>> Thanks
>> Vasu
>> 
>> 
>> 
>> 
>> 
>> 
>> >From: Sreeni Chippada <sreeni@xxxxxxxxx>
>> >Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> >To: "'xsl-list@xxxxxxxxxxxxxxxxxxxxxx'" 
>> <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>> >Subject:  Need help on sorting a dollar amount.
>> >Date: Sat, 26 Oct 2002 17:34:04 -0400
>> >
>> >Hi,
>> >	I am trying to sort on dollar amount. The value is 
>> grouped by comma.
>> >	I tried to do like this:
>> >
>> >	<xsl:when test="$location-sort-mode='mrc'">
>> >		<xsl:apply-templates
>> >select="Location[./LocationName/text()]/MRC">
>> >			<xsl:sort select="traslate(., ',', '')"
>> >data-type="number" order="{$location-sort-order}"/>
>> >		</xsl:apply-templates>
>> >	</xsl:when>
>> >
>> >	That does not work. Appreciate any help.
>> >
>> >Thanks,
>> >Sreeni
>> >
>> >
>> >  XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list


_________________________________________________________________
Unlimited Internet access for only $21.95/month.? Try MSN! 
http://resourcecenter.msn.com/access/plans/2monthsfree.asp


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

 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.