  | |  | More % sign tokenisation | More % sign tokenisation 2003-04-07 - By Greg McCreath
Hi all, My input document contains lines that have multiple 'tokens' that need replacing with xml nodes. Tokens are identified by a percent sign. An example of a input line with tokens looks like the following: "Welcome %name1 %name2. You have received a bonus of %bonus points. Your points expire on %expire365" It would be converted to : <line>Welcome <field key="name1"/> <field key="name2"/>. You have received a bonus of <field key="bonus"/> points. Your points expire on <field key="expiry" param="365"/></line> Not being an XSL guru, I can't seem to find any way of successively performing multiple operation on a string in this fashion. That is, replacing all tokens of like, say, %name1, and then doing %name2 and so on. With no 'variables' this seems a little awkward. Can anyone provide an example or some hints on how I might replace a number of different tokens in a string? Many thanks. Greg.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD><TITLE>Message</TITLE> <META http-equiv=Content-Type content="text/html; charset=us-ascii"> <META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD> <BODY> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2><SPAN class=889393608-07042003>Hi all,</SPAN></FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2><SPAN class=889393608-07042003></SPAN></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>My input document contains lines that have multiple 'tokens' that need replacing with xml nodes. Tokens are identified by a percent sign. An example of a input line with tokens looks like the following:</FONT></SPAN></DIV> <DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>"Welcome %name1 %name2. You have received a bonus of %bonus points. Your points expire on %expire365"</FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>It would be converted to :</FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003> <DIV><SPAN class=101560107-07042003><FONT face=Arial><FONT size=2><line>Welcome <field key="name1"<SPAN class=889393608-07042003>/</SPAN>> <field key="name2"<SPAN class=889393608-07042003>/</SPAN>>. You have received a bonus of <field key="bonus"<SPAN class=889393608-07042003>/</SPAN>> points. Your points expire on <field key="expiry" param="365"<SPAN class=889393608-07042003>/</SPAN>><SPAN class=101560107-07042003></line></SPAN></FONT></FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV><FONT face=Arial size=2>Not being an XSL guru, I can't seem to find any way of successively performing multiple operation on a string in this fashion. That is, replacing all tokens of like, say, %name1, and then doing %name2 and so on.</FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>With no 'variables' this seems a little awkward. Can anyone provide an example or some hints on how I might replace a number of different tokens in a string?</FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>Many thanks.</FONT></SPAN></DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2></FONT></SPAN> </DIV> <DIV><SPAN class=101560107-07042003><FONT face=Arial size=2>Greg.</FONT></SPAN></DIV></DIV> <DIV> </DIV></BODY></HTML>
|
|
|