Hi Aman,

You can use the iterate mediator [1] to iterate through each Input element.
Please find the sample below and please note that I have renamed name of
the Input1 and Input2 elements as Input in the registry entry.

<property
expression="get-property('registry','conf:/CollectionTest/LocalEntryFile.xml')"
          name="EntryFile"
          scope="default"
          type="OM"/>
<enrich>
    <source clone="true" property="EntryFile" type="property"/>
    <target type="body"/>
</enrich>
<iterate expression="//ns:Input" id="itemsIterator">
<target>
    <sequence>
        <filter regex="true"
                source="boolean(//*[local-name()='A']) and
boolean(//*[local-name()='B']) and boolean(//*[local-name()='C']) and
boolean(//*[local-name()='D']) and boolean(//*[local-name()='E']) and
boolean(//*[local-name()='F'])">
            <then>
                <log level="custom">
                    <property name="FirstLogProperty"
value="==========================FIRST"/>
                </log>
            </then>
            <else>
                <log level="custom">
                    <property name="SecondLogProperty"
value="==========================SECOND"/>
                </log>
            </else>
        </filter>
    </sequence>
</target>
</iterate>

Registry Entry:
<localEntry key="LocalEntryFile" xmlns="http://ws.apache.org/ns/synapse";>
    <list>
<Input>
           <A>value</A>
<B>value</B>
<C>value</C>
<D>value</D>
<E>value</E>
<F>value</F>
</Input>
<Input>
<A>value</A>
<B>value</B>
<C>value</C>
</Input>
    </list>
</localEntry>

[1] https://docs.wso2.com/display/EI630/Iterate+Mediator

Thanks

On Wed, Sep 19, 2018 at 4:37 PM Aman Singh <[email protected]> wrote:

> Hi All,
>
> I have a simple local-entry file, where I can store 2 inputs as an XML and
> depending on the input I can parse that XML to route to one condition or
> the other.
>
> Below are the 2 input I can insert in same local-entry file:-
>
> *Input 1:-*
> <localEntry key="LocalEntryFile" xmlns="http://ws.apache.org/ns/synapse";>
>     <list>
>              <A>value</A>
> <B>value</B>
> <C>value</C>
> <D>value</D>
> <E>value</E>
> <F>value</F>
>     </list>
> </localEntry>
>
> *Input 2:-  *
> <localEntry key="LocalEntryFile" xmlns="http://ws.apache.org/ns/synapse";>
>     <list>
>            <A>value</A>
> <B>value</B>
> <C>value</C>
>     </list>
> </localEntry>
>
> I am routing using filter mediator as below depending on the input I use
> in my local-entry file, my filter condition is:-
> <property
> expression="get-property('registry','conf:/CollectionTest/LocalEntryFile.xml')"
> name="EntryFile" scope="default" type="OM"/>
> <filter regex="true" source="boolean($ctx:EntryFile//*[local-name()='A'])
> and boolean($ctx:EntryFile//*[local-name()='B']) and
> boolean($ctx:EntryFile//*[local-name()='C']) and
> boolean($ctx:EntryFile//*[local-name()='D']) and
> boolean($ctx:EntryFile//*[local-name()='E']) and
> boolean($ctx:EntryFile//*[local-name()='F'])">
>                 <then>
>                     <log level="custom">
>                         <property name="FirstLogProperty"
> value="==========================FIRST"/>
>                     </log>
>                 </then>
>                 <else>
>                     <log level="custom">
>                         <property name="SecondLogProperty"
> value="==========================SECOND"/>
>                     </log>
>                 </else>
>             </filter>
>
> But what I want is suppose I inserted both input in Local entry as below :-
> <localEntry key="LocalEntryFile" xmlns="http://ws.apache.org/ns/synapse";>
>     <list>
> <Input1>
>            <A>value</A>
> <B>value</B>
> <C>value</C>
> <D>value</D>
> <E>value</E>
> <F>value</F>
> </Input1>
> <Input2>
> <A>value</A>
> <B>value</B>
> <C>value</C>
> </Input2>
>     </list>
> </localEntry>
>
> Then I want it to execute for both. How can I achieve this? Help would be
> appreciated.
>
> Thank you,
> Aman.
>
> _______________________________________________
> Dev mailing list
> [email protected]
> http://wso2.org/cgi-bin/mailman/listinfo/dev
>


-- 
Shakila Sasikaran
Software Engineer
Mobile :+94 (0) 77 526 6848
[email protected]
WSO2, Inc.
lean . enterprise . middleware
http://www.wso2.com/
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to