Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help with substring-before

    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:

    Code:
    <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:

    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...

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by xsl-newb View Post
    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:

    Code:
    <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:

    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?
    Code:
    <xsl:value-of select="substring-before(winning-digits,',')"/>
    best regards

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That is exactly what I needed! Thanks a lot!

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by xsl-newb View Post
    That is exactly what I needed! Thanks a lot!
    you are welcome,

    probably this will help you:

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

    best regards


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •