...

View Full Version : Help with substring-before



xsl-newb
04-14-2009, 07:38 PM
I have researched the forums and elsewhere and am now comfortable with using "substring-before". However, I am unable to figure out how to use it in a specific scenario.

Here is a piece of the XML I'm looking to transform:


<prize prize_no="6221" prize_name="Big Winner">
<winning_digits>154-902-342-542-991, Extra: 840</winning_digits>
</prize>

Here is a piece of my XSL code:


<WinningNumbers>
<xsl:attribute name="dt:dt">string</xsl:attribute>
<xsl:value-of select="winning_digits" />
</WinningNumbers>

What I'm trying to do is only parse the following from <winning_digits>: 154-902-342-542-991. Basically, everything before the comma. I can't figure out how to get substring-before to work with the specific selection of "winning_digits".

Thanks in advance for any help here...

oesxyl
04-14-2009, 08:18 PM
I have researched the forums and elsewhere and am now comfortable with using "substring-before". However, I am unable to figure out how to use it in a specific scenario.

Here is a piece of the XML I'm looking to transform:


<prize prize_no="6221" prize_name="Big Winner">
<winning_digits>154-902-342-542-991, Extra: 840</winning_digits>
</prize>

Here is a piece of my XSL code:


<WinningNumbers>
<xsl:attribute name="dt:dt">string</xsl:attribute>
<xsl:value-of select="winning_digits" />
</WinningNumbers>

What I'm trying to do is only parse the following from <winning_digits>: 154-902-342-542-991. Basically, everything before the comma. I can't figure out how to get substring-before to work with the specific selection of "winning_digits".

Thanks in advance for any help here...
"to parse" is too generic, maybe if you provide more details about what you want to could help you more.
Anyway this is what you want?


<xsl:value-of select="substring-before(winning-digits,',')"/>


best regards

xsl-newb
04-14-2009, 08:32 PM
That is exactly what I needed! Thanks a lot!:thumbsup:

oesxyl
04-14-2009, 08:35 PM
That is exactly what I needed! Thanks a lot!:thumbsup:
you are welcome, :)

probably this will help you:

http://zvon.org/xxl/XSLTreference/Output/index.html

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum