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 3 of 3
  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How do I split/divide a string in XSL?

    This is my code and the only thing that is not working is that I am getting a time like this:
    Code:
    2012-03-24T15:00:00+00:00
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
    <xsl:template match="/">
      <html>
      <body>
    
      <table border="1">
        <tr bgcolor="#9acd32">
          <th>Event</th>
          <th>Group</th>
          <th>Time</th>
        </tr>
    
        <xsl:for-each select="Diary/Event">      
    		<xsl:if test="@Classification = ''Some classification">
    			<tr>
    			  <td><a href="http://www.example.com/somepage.php" target="_blank"><xsl:value-of select="@EventName"/></a></td>
    			  <td><xsl:value-of select="@EventGroup"/></td>
    			  <td><xsl:value-of select="@Time"/></td>
    			</tr>
    		</xsl:if>
        </xsl:for-each>
    
      </table>
      </body>
      </html>
    </xsl:template>
    
    </xsl:stylesheet>
    Do you know what do I need to add in order to split the string of the time? Can you show an example please?

    Thanks!

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,344
    Thanks
    13
    Thanked 349 Times in 345 Posts
    there are several XPath functions capable of this (noteably substring(), substring-before(), substring-after(), tokenize())
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    New Coder
    Join Date
    Nov 2011
    Posts
    59
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you very much! worked


  •  

    Posting Permissions

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