on 12-01-2009 4:01 AM
Hi Experts,
The requirement is- we have a phone number (for e.g. 07 9277 1922). now we want only '07' from this. How we can do this using XSLT?
Many thanks in advance.
Edited by: Mohan Arya on Dec 1, 2009 5:02 AM
instead of using substring() method, I'd use a more flexible way : split(String regex) method that returns an array of String according to the regular expression provided as input param, like this :
String[] token = "XX xx xxxx xxx xxx".split(" ");
return token[0];
of course, you must test array is not empty, maybe catch exceptions, etc ...
Rgds
Chris
PS: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html#split(java.lang.String)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Arya,
Check this link
http://www.w3schools.com/Xpath/xpath_functions.asp
Above link in Functions on strings available, check SubString function
Ex:
Example: substring('Beatles',1,4)
Result: 'Beat'
Example: substring('Beatles',2)
Result: 'eatles'
Regards
Ramesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
<xsl:template match="/aaa">
<xxx>
<xsl:value-of select="substring(.,1,3)"/>
</xxx>
</xsl:template>
in this if you give <aaa>SAP PI XSLT</aaa>
then output will be <xxx>SAP</xxx>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Mohan,
There are predefined methods available to split the string(SubString function)
or
use JAVA code in XSLT Mapping,its very easy,use subString function,it will work it out.
or
use UDF ,use substring function in JAVA ,you can achieve easily.
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.