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 July 29th, 2008, 12:53 AM
Authorized User
 
Join Date: Jul 2008
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..."/>
 
Old July 29th, 2008, 04:26 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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





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





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