| 
 
Subject: RE: [xsl] tokenize() a string and then create a node-set From: "Bjorndahl, Brad" <brad.bjorndahl@xxxxxxxxxxxxxxxx> Date: Fri, 1 Jun 2007 10:42:44 -0400  | 
Hi,
Something like this should work. This assumes there are at least 2
substrings in $string.
<xsl:variable name="splitName" select="tokenize($string,' ')" />
<firstname><xsl:value-of select="$splitName[1]" /></firstname>
<lastname><xsl:value-of select="$splitName[last()]" /></lastname>
<xsl:choose>
  <xsl:when test="count($splitName) gt 2" >
    <midname><xsl:value-of select="for $c in (2 to last()-1) return
$splitName[$c]" /></midname>
  </xsl:when>
  <xsl:otherwise>
    <midname />
  </xsl:otherwise>
</xsl:choose>
This is not tested. I forget if you'll get spaces between midname
substrings, but I think so.
If not, you can "return ($splitName[$c],' ')".
Brad
-----Original Message-----
From: hajduk@xxxxxxxx [mailto:hajduk@xxxxxxxx]
Sent: June 1, 2007 10:21 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] 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 | 
|---|
  | 
| <- Previous | Index | Next -> | 
|---|---|---|
| RE: [xsl] tokenize() a string and t, Mario Madunic | Thread | Re: [xsl] NFA to DFA conversion usi, Mukul Gandhi | 
| RE: [xsl] tokenize() a string and t, Michael Kay | Date | RE: [xsl] tokenize() a string and t, Mario Madunic | 
| Month |