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 August 29th, 2013, 07:04 AM
Authorized User
 
Join Date: Jun 2013
Posts: 21
Thanks: 2
Thanked 0 Times in 0 Posts
Default How to find adjacent alphanumeric number

Hi All,

This is my xml
Code:
<namelist>
 <order>
     <name>JAMES</name>
      <accNo>10D</accNo>
 </order>
 <order>
      <name>ARAFAT</name>
      <accNo>07A</accNo>
 </order>
 <order>
       <name>anotherbranchaccount</name>
       <accNo>20J</accNo>
 </order>
 <order>
       <name>JAMES</name>
       <accNo>20K</accNo>
 </order>
 <order>
      <name>JOHN</name>
      <accNo>9A</accNo>
 </order>
 <order>
      <name>anotherbranchaccount</name>
      <accNo>10E</accNo>
 </order>
</namelist>
Expected output

JAMES 10D ANOTHERACCOUNT 10E
ARAFAT 07A
JAMES 20K ANOTHERACCOUNT 20J

My problem

I got to match with 'anotherbranchaccount'element which accNo is adjacent to JAMES 'accNo' .There is no sequence like main account number then extra account node.
Give me solution. I dont have any idea about that.because we have many alphanumeric comibanations like [A-Z][1 TO 100]
How to solve this issue? Please help me out.
 
Old August 29th, 2013, 09:36 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

You could sort by something like this to sort by number, then character:

Code:
<xsl:for-each select="order">
   <xsl:sort select="translate(accNo, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '')" data-type="number"/>
   <xsl:sort select="translate(accNo, '0123456789', '')" data-type="text"/>
 <!-- do something in here -->
</xsl:for-each>
The translate function would replace all of the characters in the first string with the corresponding character in the second string, which if this doesn't exists effectively deletes the character.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find number in datagridview? draganp71 Visual Basic 2008 Essentials 0 May 22nd, 2010 09:32 AM
Find line number of text JohnBampton XSLT 8 August 17th, 2009 09:20 AM
How to find line number FileFound Visual Studio 2005 2 June 15th, 2007 05:19 AM
Number and letters (alphanumeric values) jorluiseptor Classic ASP XML 0 April 22nd, 2005 03:07 PM
find maximum number Abhinav_jain_mca SQL Server 2000 4 September 28th, 2004 08:13 AM





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