Page 1 of 1
SPLIT DATA IN VARIABLE
Posted: Thu Dec 19, 2013 3:27 pm
by Le Basque
Hi,
I have data xml
I would like to make a SPLIT on the # character and retrieve each value in variable named
For the following result :
Code: Select all
var1="1"
var2="2"
var3="3"
var4="4"
Can you help me ?
Thank you
Re: SPLIT DATA IN VARIABLE
Posted: Thu Dec 19, 2013 6:17 pm
by adrian
Hi,
You can use the tokenize XSLT 2.0 function:
http://www.w3schools.com/xpath/xpath_functions.asp
e.g.
tokenize('1#2#3#4', '#')
will give you the 4 tokens(1, 2, 3, 4).
Code: Select all
<xsl:template match="x">
<xsl:for-each select="tokenize(text(), '#')">
<xsl:variable name="token" select="."/>
</xsl:for-each>
</xsl:template>
Regards,
Adrian
Re: SPLIT DATA IN VARIABLE
Posted: Thu Dec 19, 2013 6:29 pm
by Le Basque
i use xslt V1.0
I use a solution not terrible
Code: Select all
<xsl:variable name="var" select="xx"/>
<xsl:variable name="var1" select="substring-before($var, '#')"/>
<xsl:variable name="tmp" select="substring-after($var, '#')"/>
<xsl:variable name="var2" select="substring-before($tmp, '#')"/>
<xsl:variable name="tmp1" select="substring-after($tmp, '#')"/>
...