|
Home > Archive > BizTalk Server General > November 2004 > Filtering records from a message 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 records from a message using a map
|
|
|
| I have developed a map (with two inputs and one output) that is able to
filter out records from one message by looking up filter values from another
message. Its a bit of a hack, but it does use all "out of the box" BizTalk
functoids to achieve it - and does it all in one step too.
For example, given a source message of:
<order id = "1"/>
<order id = "2"/>
<order id = "3"/>
<order id = "4"/>
and a filter message of:
<order id = "2"/>
<order id = "4"/>
you get a result message of:
<order id = "1"/>
<order id = "3"/>
If any one is interested I will post the sources here.
| |
| Nabeel Prior 2004-11-22, 7:46 am |
| Please post the source - this sounds cool
--
Kind Regards,
Nabeel Prior
Web: http://www.brainjar.co.za
Blog: http://www.brainjar.co.za/blog.aspx
"Xerox" <Xerox@discussions.microsoft.com> wrote in message
news:60E4A97D-D39A-4885-A77C-DBBDCAE467C9@microsoft.com...
>I have developed a map (with two inputs and one output) that is able to
> filter out records from one message by looking up filter values from
> another
> message. Its a bit of a hack, but it does use all "out of the box" BizTalk
> functoids to achieve it - and does it all in one step too.
>
> For example, given a source message of:
>
> <order id = "1"/>
> <order id = "2"/>
> <order id = "3"/>
> <order id = "4"/>
>
> and a filter message of:
>
> <order id = "2"/>
> <order id = "4"/>
>
> you get a result message of:
>
> <order id = "1"/>
> <order id = "3"/>
>
> If any one is interested I will post the sources here.
| |
|
| I am pasting three files in to this posting. The first is the schema (there
is only one - it is used for both inputs and output). The second is a test
file that you can run from within Visual Studio - the test file is structured
for use with multi-source maps. The third is the map file itself.
Copy and paste each of the contents in to a file in the same directory. The
name of the file is listed with each.
How it works: (okay, its not elegant but it works!)
1. A cumulative string concatenate is used on all of the fields in the
second message. Each field is wrapped by a comma to make sure that it is
distinct
2. A string find functoid is used to find the source field in the
concatenated string.
3. If found then the record is output, otherwise not
I have tried this out on a test message containing 3000 source records and
1000 filter records and it took about 3 minutes in Visual Studio. I wanted to
know what was going on in the map so I put a counter in - and was very
surprised to find out that the effect of a cumulative concatenate and a loop
had a multiplicative effect on the looping: it looped about 1 million times!
I don't know why it does that, it should only be looping for as many source
records there are ie. 3000 times.
I also tried using a Hashtable as a lookup rather than searching the
concatenated string but it made little difference to performance. The
performance hit it due to the multiplicative looping.
If you can find a way of improving it then let me know.
***************************
***************** Schema1.xsd **********
***************************
<?xml version="1.0" encoding="utf-16"?>
<xs:schema xmlns="http://SBR.Support.Filter.Schema1"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
targetNamespace="http://SBR.Support.Filter.Schema1"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" name="Record">
<xs:complexType>
<xs:attribute name="Field" type="xs:string" />
<xs:attribute name="Value" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
***************************
***************** MultiSourceMapTest.xml **********
***************************
<ns0:Root xmlns:ns0="http://schemas.microsoft.com/BizTalk/2003/aggschema">
<InputMessagePart_0>
<ns1:Root xmlns:ns1="http://SBR.Support.Filter.Schema1">
<Record Field="100" Value = "one" />
<Record Field="200" Value = "two" />
<Record Field="300" Value = "three" />
<Record Field="600" Value = "seven" />
<Record Field="400" Value = "four" />
<Record Field="500" Value = "five" />
<Record Field="600" Value = "six" />
</ns1:Root>
</InputMessagePart_0>
<InputMessagePart_1>
<ns1:Root xmlns:ns1="http://SBR.Support.Filter.Schema1">
<Record Field="00" Value = "" />
<Record Field="10" Value = "" />
<Record Field="20" Value = "" />
<Record Field="30" Value = "" />
<Record Field="40" Value = "" />
<Record Field="200" Value = "" />
<Record Field="50" Value = "" />
<Record Field="60" Value = "" />
<Record Field="70" Value = "" />
<Record Field="600" Value = "" />
<Record Field="80" Value = "" />
<Record Field="90" Value = "" />
</ns1:Root>
</InputMessagePart_1>
</ns0:Root>
***************************
***************** Transform_1.btm **********
***************************
<?xml version="1.0" encoding="utf-16"?>
<!-- Generated using BizTalk Mapper on Mon, Nov 22 2004 12:01:46 PM -->
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<mapsource Name="BizTalk Map" BizTalkServerMapperTool_Version="2.0"
Version="2" XRange="100" YRange="420" OmitXmlDeclaration="Yes" CopyPIs="No"
method="xml" xmlVersion="1.0"
IgnoreNamespacesForLinks="Yes"><SrcTree><xs:schema
xmlns:tns="http://schemas.microsoft.com/BizTalk/2003/aggschema"
xmlns:ns1="http://SBR.Support.Filter.Schema1"
xmlns:b="http://schemas.microsoft.com/BizTalk/2003"
targetNamespace="http://schemas.microsoft.com/BizTalk/2003/aggschema"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import schemaLocation=".\schema1.xsd"
namespace="http://SBR.Support.Filter.Schema1"/>
<xs:element name="Root">
<xs:complexType>
<xs:sequence>
<xs:element name="InputMessagePart_0">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:Root"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="InputMessagePart_1">
<xs:complexType>
<xs:sequence>
<xs:element ref="ns1:Root"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema></SrcTree><TrgTree><Reference
Location=".\schema1.xsd"/></TrgTree><ScriptTypePrecedence><CSharp
Enabled="Yes"/><ExternalAssembly Enabled="Yes"/><VbNet
Enabled="Yes"/><JScript Enabled="Yes"/><XsltCallTemplate Enabled="Yes"/><Xslt
Enabled="Yes"/></ScriptTypePrecedence><TreeValues><TestValues/><ConstantValues/></TreeValues><Pages><Page
Name="Page 1"><Links><Link LinkID="1"
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='InputMessagePart_1']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Field']"
LinkTo="2" Label=""/><Link LinkID="2" LinkFrom="2" LinkTo="1" Label=""/><Link
LinkID="3" LinkFrom="1" LinkTo="3" Label=""/><Link LinkID="4"
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='InputMessagePart_0']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Field']"
LinkTo="3" Label=""/><Link LinkID="5" LinkFrom="3" LinkTo="4" Label=""/><Link
LinkID="6" LinkFrom="4"
LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']"
Label=""/><Link LinkID="7"
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='InputMessagePart_0']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Field']"
LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Field']"
Label=""/><Link LinkID="8"
LinkFrom="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='InputMessagePart_0']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Value']"
LinkTo="/*[local-name()='<Schema>']/*[local-name()='Root']/*[local-name()='Record']/@*[local-name()='Value']"
Label=""/></Links><Functoids><Functoid FunctoidID="1" X-Cell="52"
Y-Cell="208" Functoid-FID="328" Functoid-Name="Cumulative Concatenate"
Label=""><Input-Parameters><Parameter Type="Link" Value="2"
Guid="{D67F3E1E-905D-4189-AA3C-60AE225AAF93}"/></Input-Parameters></Functoid><Functoid
FunctoidID="2" X-Cell="49" Y-Cell="209" Functoid-FID="107"
Functoid-Name="String Concatenate" Label=""><Input-Parameters><Parameter
Type="Constant" Value=","
Guid="{932D1B93-6F37-45EA-8818-A4B1FDC666B0}"/><Parameter Type="Link"
Value="1" Guid="{BEE5B08E-729F-4499-ADB6-20A75C08F72B}"/><Parameter
Type="Constant" Value=","
Guid="{E0A53AD9-A0E4-4D2A-87F9-45B29A20CE66}"/></Input-Parameters></Functoid><Functoid
FunctoidID="3" X-Cell="53" Y-Cell="206" Functoid-FID="101"
Functoid-Name="String Find" Label=""><Input-Parameters><Parameter Type="Link"
Value="3" Guid="{383A8EE0-7A5B-417C-8A98-17D99306D430}"/><Parameter
Type="Link" Value="4"
Guid="{C8D3EECA-2B99-426C-AD98-7F1E18A5FD4E}"/></Input-Parameters></Functoid><Functoid
FunctoidID="4" X-Cell="54" Y-Cell="203" Functoid-FID="316" Functoid-Name="Not
Equal" Label=""><Input-Parameters><Parameter Type="Link" Value="5"
Guid="{95EBFAA1-1F59-460B-A52E-16FF31509751}"/><Parameter Type="Constant"
Value="0"
Guid="{DFD0EDFD-EABE-4EB8-BDF6-00A34DC4CA8C}"/></Input-Parameters></Functoid></Functoids></Page></Pages></mapsource>
|
|
|
|
|