Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 29th, 2008, 12:53 AM
Authorized User
 
Join Date: Jul 2008
Location: , , .
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL 1.0 : How to find 8th position from string


I have value of ArticleString in the attirbute of input xml such as

<InvoiceItem ArticleString="16.4.15.1.A.AC.F.P">

How to find 8th position either by using substring or any other soultion ?

[u]Expected output:</u> P

[u]Note: </u> Should not use last position to find P. Need to find the 8th position from the @ArticleString

[u]Example:</u> Other than using no of substring-after any other soultion available...? Just by passing postion number and return the value...?
<xsl:value-of select="substring-after(substring-after(substring-after(substring-after(@ArticleString,'.'),'.'),'.'),'.') etc..."/>
Reply With Quote
  #2 (permalink)  
Old July 29th, 2008, 04:26 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You've been asking a lot of questions here by now, so you should know that it's a good idea to say whether you want an XSLT 1.0 or 2.0 solution. (You can't expect us to remember from your previous posts.)

In 2.0, it's tokenize(@ArticleString, '\.').

In 1.0 you could use the EXSLT str:tokenize the same way.

You could write a recursive template that returns the $Nth substring by returning substring-before($arg,'.') if $N is 1, otherwise calling itself with arguments substring-after($arg, '.') and $N - 1.

Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XML, XSL:FO- saving position() mikevn123 XSLT 0 August 8th, 2006 02:51 PM
Sorting a xsl:if test="position()" charmaigne XSLT 2 April 12th, 2006 04:42 AM
Find a windows size and position Rowshay Visual Basic 2005 Basics 0 March 20th, 2006 01:02 AM
combining a form input name with xsl position() ? joeprice XSLT 1 February 23rd, 2006 09:54 AM
XSL Transform with xsl string NOT xsl file skin XSLT 0 June 16th, 2003 07:30 AM



All times are GMT -4. The time now is 02:10 PM.


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