[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: TOKENISER

Subject: Re: TOKENISER
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Feb 2002 14:22:07 +0000
xalan tokenize example
Hi Jinkx,

> i have a variable day defined as
> <xsl:variable name = "day" select="/date"/>
>
> which has a value Tuesday 26 February 2002
>
> can i separate each of them to get
>
> Tuesday
> 26
> February
> 2002
>
> using some kind of string functions in xsl..

There isn't a tokenising function built-in to XPath 1.0. You have
several options, though:

Since you know the format, you can pull out the strings one at a time:

  <xsl:variable name="weekday" select="substring-before($day, ' ')" />
  <xsl:variable name="monthday"
    select="substring-before(substring-after($day, ' '), ' ')" />
  <xsl:variable name="month"
    select="substring-before(
              substring-after(
                substring-after($day, ' '), ' '), ' ')" />
  <xsl:variable name="year"
    select="substring-after(
              substring-after(
                substring-after($day, ' '), ' '), ' ')" />

Or you could write your own (or copy from e.g.
http://www.exslt.org/str/functions/tokenize/str.tokenize.template.xsl)
recursive function to split the string into tokens.

Or you could use an extension function, if your processor has one, to
do this. For example, Saxon has saxon:tokenize() and Xalan has
xalan:tokenize().
                
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • TOKENISER
    • Jinkx - Wed, 27 Feb 2002 08:42:50 -0500 (EST)
      • cutlass - Wed, 27 Feb 2002 08:57:15 -0500 (EST)
      • Jeni Tennison - Wed, 27 Feb 2002 09:18:40 -0500 (EST) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.