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 May 22nd, 2006, 03:39 AM
Authorized User
 
Join Date: Apr 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default Delimited data

I've spent the last couple of working days getting nowhere with this so I hope someone can help. I'm trying to extract data from a delimited string i.e.

Code:
<FreeText>U2..123-Y/MAN-0900/STN-1200/TKT-1/GBP/A1-..50.00/T-.20.00/CF-ROSSTEST</FreeText>
I've used recursive calls to output the whole string element by element, but in this particular case I want just the 5th item (GBP). I've done the following which works, but is a little long winded.

Code:
<Fare Currency="{substring-before(substring-after(substring-after(substring-after(substring-after(FreeText, '/'), '/'), '/'), '/'), '/')}">
However, when I need the 6th, 7th.... etc. the number of "substring-after"s increases and is starting to get more difficult to interpret/read. Also, sometimes I only need a substring of the data (i.e. from the 2nd element I need to create an XML tag with just the first 3 characters ("MAN") and for another XML tag I need the last 4 converted to hh:mm format

As I have different "Freetext" lines containing different delimited data, I was going to set up templates passing in the data & the number of the element I need.

Any ideas anyone??

thanks in advance
 
Old May 22nd, 2006, 05:01 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

This kind of thing becomes much easier in XSLT 2.0.

If you're stuck with 1.0, you might find there are things you can exploit in the EXSLT library at www.exslt.org

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 22nd, 2006, 05:10 AM
Authorized User
 
Join Date: Apr 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Michael - there are some handy things in there.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Generating a comma-delimited data in XSLT dude153 XSLT 2 November 30th, 2007 12:12 PM
Importing Delimited Text sdilucca Access 1 February 23rd, 2006 02:20 PM
Delimited to select list? nameless XSLT 1 January 19th, 2006 08:04 PM
Sorting a delimited attribute pielati XSLT 1 July 1st, 2004 08:45 AM
Comma Delimited Update? mariakovacs Access ASP 6 October 13th, 2003 03:49 PM





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