[thelist] substring-after function in xslt

Gary McPherson genyus at ingenyus.net
Wed Jul 2 04:53:16 CDT 2003


> I have:
> 
> ====//====
> <xsl:variable name="sString" select="string(concat( 'From : 
> ', $iChange, ' To : ' ))"/>
> 
> where $iChange = 3
> ====//====
> 
> Using the variable in :
> 
> ====//====
> <xsl:variable name="iChange1" select="substring-before( 
> substring-after($sChangesString, $sString), ',')"/>
> 
> where $sChangesString = "From 3 To : 50,"
> ====//====
> 
> when i output $iChange1, i get nothing as oppose to getting 50.
> 
> What could be the problem?
> 
> Please please assist!

I just woke up after 4 hours sleep so I may be a little fuzzy, but
taking a quick look at your code - you're effectively calling

substring-after("From : 3 To : 50,","From 3 To : 50")

substring-after returns an empty string when the searched term is not
found and as you're missing a colon in the search term, you'll never get
the result you're looking for. It may help in future if you output the
parameters you're providing when a function is not producing the result
you expect.

HTH,

Gary




More information about the thelist mailing list