Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
3 replies Latest Post - ‏2013-01-11T13:35:50Z by samanderson
samanderson
samanderson
172 Posts
ACCEPTED ANSWER

Pinned topic substring before white space

‏2013-01-11T07:38:23Z |
Hi Frnds -

I have an element value 'abc xyz'. How to separate the using substring after before to abc and xyz using xslt ?
Updated on 2013-01-11T13:35:50Z at 2013-01-11T13:35:50Z by samanderson
  • Daviiid
    Daviiid
    282 Posts
    ACCEPTED ANSWER

    Re: substring before white space

    ‏2013-01-11T08:13:14Z  in response to samanderson
    Hello

    This styleSheet should be help you

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" xmlns:str="http://exslt.org/strings">
            <xsl:template match="/">
                    <xsl:for-each select="str:split('abc xyz',' ')">
                            <result><xsl:value-of select="."/></result>
                    </xsl:for-each>
     
            </xsl:template>
    </xsl:stylesheet>
    
    Updated on 2014-03-25T02:42:11Z at 2014-03-25T02:42:11Z by iron-man
    • samanderson
      samanderson
      172 Posts
      ACCEPTED ANSWER

      Re: substring before white space

      ‏2013-01-11T13:35:50Z  in response to Daviiid
      Thanks mate I know sub string way. checking for otherways like split.
  • Daviiid
    Daviiid
    282 Posts
    ACCEPTED ANSWER

    Re: substring before white space

    ‏2013-01-11T08:23:23Z  in response to samanderson
    Or

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dp="http://www.datapower.com/extensions" extension-element-prefixes="dp" xmlns:str="http://exslt.org/strings">
            <xsl:template match="/">
                    <xsl:value-of select="substring-before('aaa bbbc',' ')"/>
                    <xsl:value-of select="substring-after('aaa bbbc',' ')"/>
     
            </xsl:template>
    </xsl:stylesheet>
    
    Updated on 2014-03-25T02:42:01Z at 2014-03-25T02:42:01Z by iron-man