Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 18th, 2010, 03:31 AM
Registered User
 
Join Date: Mar 2010
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Question XSLT Sort based on EBCDIC character set

Hi,

I need to sort XML documents in Microsoft Biztalk. I have implemented this using the XSLT sort.

Unfortunately I have found out that the sort is supposed to be based on the EBCDIC character set. The main difference between EBCDIC and, say, Unicode or ASCII, is that in EBCDIC letters come before numbers.

So I want:
ES00000122D7
USG07402AE39
US05967DAA90
US7615651004

not:
ES00000122D7
US05967DAA90
US7615651004
USG07402AE39

Any idea on how to do this. I have looked at the lang attribute but can't find any good resource on how to use it properly and if it will work for me in any case.

Thanks,

Michiel
 
Old March 18th, 2010, 04:34 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think Microsoft Biztalk is still using XSLT 1.0 so there's likely to be very little support for alternative collations, unless Microsoft have done something specific to their product. If you're only dealing with letters and digits, then a simple solution is to set up a translation table something like this:

Code:
<xsl:sort select="translate(xxxx, 'ABCDEF...Z0123456789', '0123456789ABCDEF...Z')"/>
You can obviously extend this to cover as many characters as you want. The first list should contain the characters in Unicode order, the second list in the order that you want them to collate (I think I've got that right...)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
michieldejong (March 19th, 2010)
 
Old March 19th, 2010, 04:40 AM
Registered User
 
Join Date: Mar 2010
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thanks a lot, it works like a charm.
I found out I actually need a sort where all small letters come before the capitals (abcdABCD where XSLT seems to do aAbBcCdD) but your method works for that as well.

Code:
<xsl:sort select="translate(FONDS-CODE,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789','0123456789aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ')" data-type="text" order="ascending" case-order="lower-first"/>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Sort-by attribute based on parent tclancy XSLT 2 March 24th, 2006 05:00 PM
how to sort cross tab.sort based on row total joxa83 Crystal Reports 7 March 2nd, 2006 09:12 AM
Character set muthukumar Oracle 0 November 8th, 2005 12:49 AM
Sort Records Based on Totals mvollmer Classic ASP Databases 1 July 11th, 2004 11:22 AM
How to set DOM character set sonicDace XML 0 May 27th, 2004 08:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.