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 19th, 2007, 03:50 PM
Registered User
 
Join Date: Jul 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default tokenize

<xsl:variable name="ID"><xsl:value-of select="./@id" /></xsl:variable>
the result of this is
T123, Y445, G666, Y5454

IF I want to have display like

T123
Y445
G666
Y5454

How can i do that?

I am using version 1.0
 
Old July 19th, 2007, 04:10 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly

<xsl:variable name="ID"><xsl:value-of select="./@id" /></xsl:variable>

is a ludicrously inefficient way of saying

<xsl:variable name="ID" select="./@id" />

Why create a result tree fragment when you only want a string, especially as it makes your code twice the length?

Presumably therefore you have an @id attribute containing the string

T123, Y445, G666, Y5454

You can convert this to your required output using

translate($ID, ', ', '#xa;')

However if your output is HTML then generating newlines isn't enough to have each string displayed on a newline, you need to generate <br/> elements. For that you need to tokenize the string - go to www.exslt.org and find the str:tokenize() template. It's built into some processors but if not there's an XSLT implementation you can copy into your stylesheet.

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





Similar Threads
Thread Thread Starter Forum Replies Last Post
<xsl:for-each select="tokenize($indoc,'&#xA;')"> kapy_kal XSLT 4 June 9th, 2006 07:33 AM
tokenize sakura C# 1 December 3rd, 2005 10:43 AM
Functions replace and tokenize not found. spencer.clark XSLT 2 July 20th, 2005 02:51 PM





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