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

RE: tokenize() a string and then create a node-set

Subject: RE: tokenize() a string and then create a node-set
From: Mario Madunic <hajduk@xxxxxxxx>
Date: Fri, 1 Jun 2007 08:05:52 -0700
RE:  tokenize() a string and then create a node-set
Thanks Michael and Brad,

Your help and insight is greatly appreciated.

Marijan Madunic

Quoting Michael Kay <mike@xxxxxxxxxxxx>:

> Yes, you can do 
> 
> <xsl:if test="position()=1">
>   <firstname><xsl:value-of select="."/></firstname>
> </xsl:if>
> 
> Alternatively,
> 
> <xsl:variable name="t" select="tokenize(...)"/>
> <first><xsl:value-of select="$t[1]"/></first>
> <xsl:for-each select="2 to count($t)-1">
>   <middle><xsl:value-of select="subsequence($t, ., 1)"/></middle>
> </xsl:for-each>
> <last><xsl:value-of select="$t[last()]"/></last>
> 
> Michael Kay
> http://www.saxonica.com/ 
> 
> > -----Original Message-----
> > From: hajduk@xxxxxxxx [mailto:hajduk@xxxxxxxx] 
> > Sent: 01 June 2007 15:21
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  tokenize() a string and then create a node-set
> > 
> > Haven't used the tokenize() function and just wanted a bit of insight.
> > 
> > Note, could create a called-template plus a user defined 
> > function(s) to do the following but want to see if there is 
> > an easier/other way to do it.
> > 
> > I want to take a string containing a person's name and break 
> > it apart based on a space. Then parse the result as follows. 
> > If position is first then <firstname>, if position is last 
> > then <lastname> else <midname>.
> > 
> > Can this be done using a <for-each select="tokenize($string, 
> > ' ')"> with a <choose>|<if> statement inside?
> > 
> > Any ideas will be greatly appreciated.
> > 
> > Marijan Madunic

Current Thread

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.