xsl-list
[Top] [All Lists]

Re: [xsl] Sort XML based on Tokenized String of sort by fields

2008-05-23 13:05:41




Merlin Securities - #1 Prime Broker North America and #1 Prime Broker Single 
Strategy Funds - Global Custodian 2007
#1 Prime Broker for Hedge Funds under $1 Billion - Alpha Survey 2007



From: Rebecca Sapir 
Sent: Friday, May 23, 2008 3:57 PM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: Re: [xsl] Sort XML based on Tokenized String of sort by fields

David,

Thanks so much. I have been playing around with your suggestions and they are 
great. 


Unless the number of sort keys is really unbounded, personally I'd
probably just make those two changes, add say 10 of these lines to cover
all(?) cases in practice and call it done, but....

I am sure I can safely assume that there are at most X number of sorts so I am 
tempted to do just this. But since your other suggestions would allow me to be 
more generic and not make any assumptions I would like to try those first.


The way to do this in xslt is to generate a stylesheet, you do it in two
passes, first generaate a stylesheet then execute it you can do that in
one call to saxon, if you wish with the saxon-transform extension, which
means that the generated stylesheet can just be ina variable and never
actually serialised.

I have never done something like this before but this looks like a really good 
and robust solution that will give me a lot of flexibility. I will play around 
with this and use the suggestions from the other posts. 

On the other hand it isn't clear to me that you need multiple sort keys
at all. You appear to be doing string as opposed to numeric sorting in
all cases and so doesn't a single

do the job replacing ',' by some other separator if there is any
possibility of , appearing in any of the fields.
<xsl:sort  select="string-join(for $i in $ORDER_BY_TOKEN return *[local-
name()=$i],',')"/>

This solution is great as well however I actually would want to do numeric and 
string sorts. My example was just the basics since I am taking this task 
piecemeal but there would be numeric, string and date sorts as well as 
descending vs. ascending. I am just trying to take this one step at a time. In 
actuality the string would be something like 
<ORDER_BY>DATE, ID_1, ID_2, TYPE DES, NET_AMOUNT DES</ORDER_BY>
Where DES indicates that I should sort descending.

As for the data type, that would be sent to me as well as a separate string 
within the REPORT_FORMAT section but we have yet to figure out how it will work.

In that case this solution would not work? Meaning something like
<xsl:sort  select="string-join(for $i in $ORDER_BY_TOKEN return 
*[local-name()=$i],',')" order"..." data-type="... "/>
Where the order and data type would do a similar type of selection?


Thanks SOOO much for your help.

- Rebecca


 
--------------------------------------------------------------------------
This message contains information from Merlin Securities, LLC, or from one of 
its affiliates, that may be confidential and privileged. If you are not an 
intended recipient, please refrain from any disclosure, copying, distribution 
or use of this information and note that such actions are prohibited. If you 
have received this transmission in error, please notify the sender immediately 
by telephone or by replying to this transmission.
 
Merlin Securities, LLC is a registered broker-dealer. Services offered through 
Merlin Securities, LLC are not insured by the FDIC or any other Federal 
Government Agency, are not deposits of or guaranteed by Merlin Securities, LLC 
and may lose value. Nothing in this communication shall constitute a 
solicitation or recommendation to buy or sell a particular security.



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--