Topic
  • 3 replies
  • Latest Post - ‏2013-01-11T13:35:50Z by samanderson
samanderson
samanderson
172 Posts

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
    289 Posts

    Re: substring before white space

    ‏2013-01-11T08:13:14Z  
    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
  • Daviiid
    Daviiid
    289 Posts

    Re: substring before white space

    ‏2013-01-11T08:23:23Z  
    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
  • samanderson
    samanderson
    172 Posts

    Re: substring before white space

    ‏2013-01-11T13:35:50Z  
    • Daviiid
    • ‏2013-01-11T08:13:14Z
    Hello

    This styleSheet should be help you

    <pre class="java dw" data-editor-lang="java" data-pbcklang="java" dir="ltr"><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> </pre>
    Thanks mate I know sub string way. checking for otherways like split.