BizTalk Server General - Filtering out elements from XML using a map

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > November 2004 > Filtering out elements from XML using a map





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Filtering out elements from XML using a map
Xerox

2004-11-17, 7:47 am

Hi,

If anyone can help with this problem I would greatly appreciate it: Using a
map, I want to filter out elements from one XML message based on the filter
values specified in another.

This is the source message:

<id = "1"/>
<id = "2"/>
<id = "3"/>

This is the filter message. Any values found in the filter message mean that
the corresponding elements from the source message are filtered out:

<filter = "2"/>
<filter = "3"/>

Now I have used the looping functoid in conjunction with the logical equals
functoid to similar effect before but it is not the same as in this
situation. Its more of a "lookup" or "contains" than an equals. I want the
map to say: "if item with id = 1 is found within the filters, then filter it
out".

Hope this makes sense!

Thanks.
Bryan Brouckaert

2004-11-24, 5:52 pm

Hi,

Yes it does make sense, and I think I know a solution.

First of all you have to put a cumulative concatenate on your filter (be
aware cumulative functoid take all records in the document). Configure the
concatinate so the output is something like this: "2;3;". The rest is very
much like what you did before: looping functoid between id's, and a filter.
This time the filter is not a single functoid, but chain of functoids. The
start of the chain consists of a string concatinate functoid that adds ";"
to to end of the id. The second part is a string find functoid that the
previous functoid and the cumulative functoid as inputs. The last part of
the chain is an equal functoid that has the string find and the constant 0
as inputs. The the end of the chain is connected to the destination record
to serve as a filter.

The first step creates a flattend filter string e.g. "2;3;". Then the chains
works a follows. First it creates a new id e.g. "2;" then it will retrieve
the index of the new id in the flattend filter string. If the new id is not
found the index 0 is returned, if it is found a different value is returned.
Then we check if the index is equal to 0, meaning is the new id not part the
flattend filter. Because the new id is no part of the flattend filter, the
old id is also no part of the original filter.

In the above method the cumulative concatenate is executed for every id
record. So it would not be a bad idea to create the flattend filter string
in seperate mapping. This wil reduce the prosessing time from: O(n*m²) to
O(n*m) where n is the number of id's and m is the number of filters. That
can make a big difference for large filters.

Hope this helps,
Bryan.

"Xerox" <Xerox@discussions.microsoft.com> schreef in bericht
news:02470D3B-D795-4C76-893D-7336158BDE37@microsoft.com...
Hi,

If anyone can help with this problem I would greatly appreciate it: Using a
map, I want to filter out elements from one XML message based on the filter
values specified in another.

This is the source message:

<id = "1"/>
<id = "2"/>
<id = "3"/>

This is the filter message. Any values found in the filter message mean that
the corresponding elements from the source message are filtered out:

<filter = "2"/>
<filter = "3"/>

Now I have used the looping functoid in conjunction with the logical equals
functoid to similar effect before but it is not the same as in this
situation. Its more of a "lookup" or "contains" than an equals. I want the
map to say: "if item with id = 1 is found within the filters, then filter it
out".

Hope this makes sense!

Thanks.


Xerox

2004-11-25, 7:46 am

Thanks for this Brian. Coincidentally it is the same conclusion that I had
come to several days after posting this question. Check out a later post of
mine that has the source pasted in that does exactly as you state below.

The O(n*m²) effect is unfortunate. I'd love to find a way to reduce the
looping to O(n*m) just in the one step though - but it doen't look possible.

"Bryan Brouckaert" wrote:

> Hi,
>
> Yes it does make sense, and I think I know a solution.
>
> First of all you have to put a cumulative concatenate on your filter (be
> aware cumulative functoid take all records in the document). Configure the
> concatinate so the output is something like this: "2;3;". The rest is very
> much like what you did before: looping functoid between id's, and a filter.
> This time the filter is not a single functoid, but chain of functoids. The
> start of the chain consists of a string concatinate functoid that adds ";"
> to to end of the id. The second part is a string find functoid that the
> previous functoid and the cumulative functoid as inputs. The last part of
> the chain is an equal functoid that has the string find and the constant 0
> as inputs. The the end of the chain is connected to the destination record
> to serve as a filter.
>
> The first step creates a flattend filter string e.g. "2;3;". Then the chains
> works a follows. First it creates a new id e.g. "2;" then it will retrieve
> the index of the new id in the flattend filter string. If the new id is not
> found the index 0 is returned, if it is found a different value is returned.
> Then we check if the index is equal to 0, meaning is the new id not part the
> flattend filter. Because the new id is no part of the flattend filter, the
> old id is also no part of the original filter.
>
> In the above method the cumulative concatenate is executed for every id
> record. So it would not be a bad idea to create the flattend filter string
> in seperate mapping. This wil reduce the prosessing time from: O(n*m²) to
> O(n*m) where n is the number of id's and m is the number of filters. That
> can make a big difference for large filters.
>
> Hope this helps,
> Bryan.
>
> "Xerox" <Xerox@discussions.microsoft.com> schreef in bericht
> news:02470D3B-D795-4C76-893D-7336158BDE37@microsoft.com...
> Hi,
>
> If anyone can help with this problem I would greatly appreciate it: Using a
> map, I want to filter out elements from one XML message based on the filter
> values specified in another.
>
> This is the source message:
>
> <id = "1"/>
> <id = "2"/>
> <id = "3"/>
>
> This is the filter message. Any values found in the filter message mean that
> the corresponding elements from the source message are filtered out:
>
> <filter = "2"/>
> <filter = "3"/>
>
> Now I have used the looping functoid in conjunction with the logical equals
> functoid to similar effect before but it is not the same as in this
> situation. Its more of a "lookup" or "contains" than an equals. I want the
> map to say: "if item with id = 1 is found within the filters, then filter it
> out".
>
> Hope this makes sense!
>
> Thanks.
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com