473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

XSLT sort question

samueln12
Hi,

I have the following content

Expand|Select|Wrap|Line Numbers
  1. <inline-graphic href="gkq255i1"/>
  2. <inline-graphic href="gkq255i2"/>
  3. <inline-graphic href="gkq255i3"/>
  4. <inline-graphic href="gkq255i100"/>
  5. <inline-graphic href="gkq255i10"/>
  6. <inline-graphic href="gkq255i11"/>
  7. <inline-graphic href="gkq255i99"/>
  8. <inline-graphic href="gkq255i101"/>
when i am try to sort it i am getting the following output

Expand|Select|Wrap|Line Numbers
  1. <inline-graphic href="gkq255i1"/>
  2. <inline-graphic href="gkq255i2"/>
  3. <inline-graphic href="gkq255i3"/>
  4. <inline-graphic href="gkq255i10"/>
  5. <inline-graphic href="gkq255i100"/>
  6. <inline-graphic href="gkq255i101"/>
  7. <inline-graphic href="gkq255i11"/>
  8. <inline-graphic href="gkq255i99"/>
but i required

Expand|Select|Wrap|Line Numbers
  1. <inline-graphic href="gkq255i1"/>
  2. <inline-graphic href="gkq255i2"/>
  3. <inline-graphic href="gkq255i3"/>
  4. <inline-graphic href="gkq255i10"/>
  5. <inline-graphic href="gkq255i11"/>
  6. <inline-graphic href="gkq255i99"/>
  7. <inline-graphic href="gkq255i100"/>
  8. <inline-graphic href="gkq255i101"/>
How to do this in XSLT

Thanks
Sam
Apr 28 '10 #1
4 1708
Dormilich
8,658 Expert Mod 8TB
if I read the specs right, XSLT does not implement a sorting algorithm itself (although it defines some basic options), which is left to the XSLT parser. currently I see no way to sort that this way.

i could imagine it working, if you sort primarily by attribute length and then by text order, but well …
Apr 28 '10 #2
jkmyoung
2,057 Expert 2GB
<xsl:sort select="substring-after(@href,'gkq255i')" data-type="number"/>
If the string is not consistent, get the prefacing string into a variable, and replace 'gkq255i' with the variable.
Apr 28 '10 #3
Hi ALL,

Thanks for all your support

I finally fixed by the following method

<xsl:sort select="translate(child::inline-graphic/@href, 'abcdefghijklmnopqrstuvwxyz-', '000000000000000000000000000')" data-type="number"/>

Thanks
Sam
Apr 29 '10 #4
jkmyoung
2,057 Expert 2GB
Thanks, interesting solution. Would probably not work for strings longer than 18 characters.
Apr 29 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David | last post by:
I would like to be able to re-sort data in an HTML table on the without returning to the server. It seems like an XSLT should be able to accomplish this, but I can't find enough information... ...
3
by: Phil | last post by:
Hi everybody, I am a XSLT beginner and the following problem really makes me crazy ! I have a main "contacts.xml" document which contains references to several contact data XML files. My aim...
4
by: Ringo Langly | last post by:
Hi all, I'm a seasoned web programmer, but I've never touched XSLT. It's always been one of those acronyms I've never needed to educate myself on. Now... we're working with a web content...
9
by: Eric Anderson | last post by:
Got a quick question trying to figure out the XSLT way of implementing the functionality of associative arrays. Basically want I want to do is the following: <xsl:template name="foo">...
4
by: Chris Kettenbach | last post by:
Hi Peter, I get error when processing the stylesheet. It errors here. <xsl:for-each select="registration)=1]"> specifically: Expression does not return a DOM node. registration)=1]<--
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
6
by: Michiel Kamermans | last post by:
Hi, I need to generate a list based on a sorted nodeset, except duplicates need to be discarded. I initially though of doing a sort on a nodeset and then passing it to a template that iterates...
0
by: DAnne | last post by:
Hi, I'm very new to xslt and this is my first time posting to a Forum so please forgive me if I transgress any protocols. I have to do a tally report. This report is divided up into sections....
18
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to...
7
by: pstachy | last post by:
Hi all, I'm having problem with XSLT transformation concerned with sort and numberings at a time. I wish to have my registries sorted alfabetically and would like them to have numberings at a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.