Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Is there a Mapping solution to this problem?
- This topic has 2 replies, 1 voice, and was last updated 8 years, 4 months ago by
community-content.
-
AuthorPosts
-
-
January 19, 2007 at 10:11 AM #17320
Here is my source data fragment
<ns0:TestInput xmlns:ns0="http://Some_namespace">
<PassengerCount>1</PassengerCount>
<Type>A</Type>
<BreakDown>
<Line>20JUL07LON VS NYC712.88Y2NUC712.88END ROE.507796XT14.10UB32.50 </Line>
<Line>YQ7.80US2.60XA3.60XY2.60YC </Line>
<Line>LAST VALID DATE 20JUL07 – DATE OF ORIGIN </Line>
</BreakDown>
</ns0:TestInput>and the desired output
<Passenger>
<Taxes>
<Data>
<Code>UB</Code>
<Value>14.10</Value>
</Data>
<Data>
<Code>YQ</Code>
<Value>32.50</Value>
</Data>
<Data>
<Code>US</Code>
<Value>7.80</Value>
</Data>
<Data>
<Code>XA</Code>
<Value>2.60</Value>
</Data>
</Taxes>
</PassengerData>The values for the target fragment are number+two letter codes between "XT" (in the first breadown <line> element ) and LAST in the last Breakdown <line>element. These are tax values and associated tax codes and are shown in bold in the sample input.
Caveats. 1. The number of instances of Tax value+2-letter codes will vary.
2. A given combination of Tax value + code can be split across <line> elements. All numeric values will be given to 2 decimal places
3. All Tax values + associated codes need to be mapped (although only the first 4 shown)
4. The format & content of the input document is not within my sphere of control
5. The structure and content of the target document is also not within my sphere of controls
I Would appreciate any guidance on a mapping solution if one exists.
Many thanks
-
January 19, 2007 at 6:20 PM #17335
Let's start by heading down the correct path…
You control the INTERNAL schema. You Own it, its yours. So, you map from the "interesting" input schema to your internal schema that you create that puts the data into a clean and manageable format, but only because it's a best practice and the right thing to do. Map your data in the Receive port and handle only the internal schema in your orchestration, if you need one (if not, then great…just use another map to the outbound schema.)
That said, I'd suggest as a starting point a concatenation of the <line> elements and then isolate the pattern that delineates the beginning and end of the data you care about.
Since I know I could break that data down using the FlatFile Schema Wizard, I'm sure there are methods to help you break it down. I'd probably start with string functoids, get frustrated and write a script, before searching BizTalkGurus.com and then Google.
Hope this helps, even a little bit.
-
January 22, 2007 at 1:55 AM #17341
You can use the map file Map2.btm as below[last]..
Do the following..
1.Create a schemas from ur input xml file given by you.
2.create a map Map2.btm
3.Create a dummy schema as follows
—-Rootnode1
———–Fieldelement[string]
Map the output of scripting functiod to this field element.
4 Create another Map Map3.btm
5.Input schema is the Dummy Schema created above
6.Output Schemas as below
Passenger———Rootnode
—<xs Any element>
Map the field element to the Passenger rootnode…u will get the outputyou mentioned.
you can mail me if still find it difficult…I will mail u the solution.
——————————————–Map2.btm———-
<?xml version="1.0" encoding="utf-16"?>
<!– Generated using BizTalk Mapper on Mon, Jan 22 2007 04:22:19 AM –>
<mapsource Name="BizTalk Map" BizTalkServerMapperTool_Version="2.0" Version="2" XRange="100" YRange="420" OmitXmlDeclaration="Yes" TreatElementsAsRecords="No" OptimizeValueMapping="Yes" GenerateDefaultFixedNodes="Yes" CopyPIs="No" method="xml" xmlVersion="1.0" IgnoreNamespacesForLinks="Yes">
<SrcTree>
<Reference Location=".\StringChar_Input.xsd" />
</SrcTree>
<TrgTree>
<Reference Location=".\Schema2.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()='TestInput']/*[local-name()='BreakDown']/*[local-name()='Line']" LinkTo="1" Label="" />
<Link LinkID="2" LinkFrom="1" LinkTo="3" Label="" />
<Link LinkID="3" LinkFrom="3" LinkTo="4" Label="" />
<Link LinkID="4" LinkFrom="1" LinkTo="6" Label="" />
<Link LinkID="5" LinkFrom="6" LinkTo="5" Label="" />
<Link LinkID="6" LinkFrom="1" LinkTo="2" Label="" />
<Link LinkID="7" LinkFrom="4" LinkTo="2" Label="" />
<Link LinkID="8" LinkFrom="5" LinkTo="2" Label="" />
<Link LinkID="9" LinkFrom="2" LinkTo="7" Label="" />
<Link LinkID="10" LinkFrom="7" LinkTo="/*[local-name()='<Schema>']/*[local-name()='PassengerData1']/*[local-name()='Field']" Label="" />
</Links>
<Functoids>
<Functoid FunctoidID="1" X-Cell="53" Y-Cell="215" Functoid-FID="328" Functoid-Name="Cumulative Concatenate" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="1" Guid="{033CA7BF-0B8A-4FF5-AD81-04680F9AC48D}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="2" X-Cell="57" Y-Cell="215" Functoid-FID="106" Functoid-Name="String Extract" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="6" Guid="{094BEFBA-37BD-44D6-A434-E9857B35A083}" />
<Parameter Type="Link" Value="7" Guid="{0BB8F0D7-08DF-4C23-A9F8-62A51C510258}" />
<Parameter Type="Link" Value="8" Guid="{490276A9-4D39-47B8-9722-0AC5B30E3A32}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="3" X-Cell="54" Y-Cell="213" Functoid-FID="101" Functoid-Name="String Find" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="2" Guid="{FB3CB398-D84F-4A0C-A0E8-AC296FACF4BF}" />
<Parameter Type="Constant" Value="XT" Guid="{5429782D-3043-45B9-81CD-0B68330F0747}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="4" X-Cell="56" Y-Cell="213" Functoid-FID="118" Functoid-Name="Addition" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="3" Guid="{0F92C50A-FB69-47CB-B28A-4F381E44B57E}" />
<Parameter Type="Constant" Value="2" Guid="{906BB748-9C48-436B-8F97-C8D214F6A7D7}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="5" X-Cell="56" Y-Cell="217" Functoid-FID="119" Functoid-Name="Subtraction" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="5" Guid="{8C71F161-B146-4E3D-A316-F9862F6D53A1}" />
<Parameter Type="Constant" Value="1" Guid="{7074AE22-7CA5-4BC1-A0D0-BDB37C44E00E}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="6" X-Cell="54" Y-Cell="217" Functoid-FID="101" Functoid-Name="String Find" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="4" Guid="{6877A8E0-607B-4B34-9E4C-A7539B0F6728}" />
<Parameter Type="Constant" Value="LAST" Guid="{CCFB44D1-CABE-44CC-ADC9-E305723452DE}" />
</Input-Parameters>
</Functoid>
<Functoid FunctoidID="7" X-Cell="59" Y-Cell="215" Functoid-FID="260" Functoid-Name="Scripting" Label="">
<Input-Parameters>
<Parameter Type="Link" Value="9" Guid="{D367F85B-FE51-43FD-83D3-2ECD1D3F21A2}" />
</Input-Parameters>
<ScripterCode>
<Script Language="CSharp"><![CDATA[///*Uncomment the following code for a sample Inline C# function
//that concatenates two inputs. Change the number of parameters of
//this function to be equal to the number of inputs connected to this functoid.*/public string MyConcat(string aString)
{aString = aString.Replace(" ","");
int i = 2 ;
int intIndex = 0;
int intstrCode=0;
int IntPreva2Index=0;
string strcode;
string strnumber;
string strnumberDec;
string strnumberFinal;
string strFinalOutput="<Taxes>";
int a2LastIndex = 0;
do
{
int a2 = aString.IndexOf(".",intIndex);
if (aString.Length – a2LastIndex == 5)
{
i = 3;
}
else
{
strnumberDec = aString.Substring(a2 + 1, 2);
strnumber = aString.Substring(intstrCode, a2 – IntPreva2Index);
strnumberFinal = strnumber + "." + strnumberDec;
strcode = aString.Substring(a2 + 3, 2);
intstrCode = aString.IndexOf(strcode) + 2;
IntPreva2Index = a2 + 5;
intIndex = a2 + 1;
strFinalOutput = strFinalOutput + "<Data><Code>" + strcode + "</Code><Value>" + strnumberFinal + "</Value>";
}
a2LastIndex = a2;} while (i == 2);
strFinalOutput=strFinalOutput+" </Taxes>";
return strFinalOutput;
}]]></Script>
</ScripterCode>
</Functoid>
</Functoids>
</Page>
</Pages>
</mapsource>—————————————————-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.