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

Re: Sort XML based on Tokenized String of sort by fiel

Subject: Re: Sort XML based on Tokenized String of sort by fields
From: "Rebecca Sapir" <rsapir@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 May 2008 16:04:17 -0400
Re:  Sort XML based on Tokenized String of sort by fiel
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@xxxxxxxxxxxxxxxxxxxxxx'
Subject: Re:  Sort XML based on Tokenized String of sort by fields


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

> 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
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

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.

Current Thread


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.
First Name
Last Name
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.