Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


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

From: Mario Madunic <hajduk@-------->
To:
Date: 6/1/2007 3:06:00 PM
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: [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


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent