xpress code to retrieve set of strings as separate lists from a list

Hi,

I have to write a rule that takes in a list which can contain any number of individual strings and comma separated values in each string example:

<list>

<s>A,B,C</s>

<s>A1,B1,C1,D1</s>

<s>D2,C2</s>

</list>

and the output for this rule must give me separate lists as

<list>

<s>A</s>

<s>B</s>

<s>C</s>

</list>

<list>

<s>A1</s>

<s>B1</s>

<s>C1</s>

<s>D1</s>

</list>

<list>

<s>D2</s>

<s>C2</s>

</list>

The number of lists as output depend on the number of strings given in the input list ,which is dynamic.

please help me out!

-Sanjeev

[889 byte] By [Sanjeev1028a] at [2007-11-27 6:36:21]
# 1

A few tips.

You will need to return a list of lists.

Use a dolist to loop through the strings

Use split to split the strings into the comma separated values

Sorry, I don't have time to write the code for you right now. If someone else hasn't done it in a few days' time then I will try to give it a go for you.

timboa at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...
# 2

I found a spare few minutes ;). Here you go:

<block>

<defvar name='ret'/>

<defvar name='lst'>

<list>

<s>A,B,C</s>

<s>1,2,3</s>

<s>Hello,Hola,Ni Hao</s>

</list>

</defvar>

<dolist name='str'>

<ref>lst</ref>

<append name='ret'>

<split>

<ref>str</ref>

<s>,</s>

</split>

</append>

</dolist>

<ref>ret</ref>

</block>

timboa at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...
# 3

another version without append

<RuleArgument name='arg'/>>> rule argument your list

<block trace='true'>

<defvar name='allList'>

<dolist name='el'>

<ref>arg</ref>

<split>

<ref>el</ref>

<s>,</s>

</split>

</dolist>

</defvar>

<ref>allList</ref>

</block>

cheers

rgds,

Suren

Surinder_Singh_Boraa at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...
# 4
Hey!Thanks a bunch! It worked :)
Sanjeev1028a at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...
# 5

Hi ppl..

change of requirement!

suppose i have

<Properties>

<Property name='editorOriginalName' value='SoapConfig,a,b,c:1,2,3:4,5,6:A,B,C'/>

</Properties>

and i need to pass the value of the Property 'editorOriginalName' as an argument to my rule(as list) how can i achieve this?

Sanjeev1028a at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...
# 6

Pick the vlaue of the property and call your rule as

<rule name='your rule name'>

<argument name='nameofarg'>

<split>

<ref>ur property value</ref>

<s>:</s>

</split>

</argument>

</rule>

Hope this will help.

rgds,

Suren

Surinder_Singh_Boraa at 2007-7-12 18:03:55 > top of Java-index,Web & Directory Servers,Directory Servers...