Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Conditional Flatten mapping
- This topic has 3 replies, 1 voice, and was last updated 6 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
April 19, 2006 at 9:23 AM #13367
Hi,
I need to implement the following logic:
the source is a looping nodes.
destination are flatten elemets.
condition is based on what is in <source><RepeatingParent><code><source>
<RepeatingParent>
<code>A</code>
<value>123</value>
</RepeatingParent>
<RepeatingParent>
<code>B</code>
<value>456</value>
</RepeatingParent>
<RepeatingParent>
<code>C</code>
<value>789</value>
</RepeatingParent>
</source><destination>
<codeA>123</codeA>
<codeB>456</codeB>
<codeC>789</codeC>
</destination>I am curently using the \”Index\” + \”Equal\” + \”Value Mapping\” functoid to
solve this logic:
{copy this into notepad…sorry for the poor presentation, do not know how
to do this…}<source><RepeatingParent><code>—->[INDEX(1)]—->[EQUAL(A)]:–(true)–>|
|—–> [VALUEMAPPING]—><destination><codeA>
<source><RepeatingParent><value>—->[INDEX(1)]:
———————————–>So this is a brute force kind of approach:
for a set of 3 condition, I will need 3 sets of index (spanning index 1 to
index 3).
and under each index, I am checking against all 3 condition.
this will produce 3×3=9 functoids in the map.The approach is ok for a small sets of condition(have done up to 8
conditions, producing 8×8= 64 functoids in the map),
but I need to produce a 22 conditional mapping.(22×22=484 functoids!)I am sure there is a correct way to implement this logic, but so far,
couldn’t find any help for this kind of logic on the web.
Would really appreciate your help on this.Thanks.
Stephen chai
-
April 21, 2006 at 2:14 AM #13368
Thanks !
I have used the first method using functoid b4. But the problem is the source is a loop structure where as the destination is a flat structure(my case is a tab delimited FF). I would need the source to loop for n times to get the value and put them in seperate places in dest. there is no destination to link the looping functoid.
I am currently trying the xslt method you have suggested.
It can do what is wanted. However, I ran into these 🙁because xslt run in sequential manner, the position of the element produced in destination is according to the order of the source.
SOURCE(A) <source>
<RepeatingParent>
<code>A</code>
<value>123</value>
</RepeatingParent>
<RepeatingParent>
<code>B</code>
<value>456</value>
</RepeatingParent>
</source>
PRODUCE:
<destination>
<codeA>123</codeA>
<codeB>456</codeB>
</destination>
BUT IF SOURCE(B)IS:
<source>
<RepeatingParent>
<code>B</code>
<value>456</value>
</RepeatingParent>
<RepeatingParent>
<code>A</code>
<value>123</value>
</RepeatingParent>
</source>
PRODUCE:
<destination>
<codeB>456</codeB>
<codeA>123</codeA>
</destination>
—-
so source(B) produced invalid destination structure(codeB b4 codeA).what Iam trying now is in the xslt:
a. go through all loop in source to get the value into many parameter
b. then, after that create destination accordingly using the parameter.this should work, but I foresee another problem.
because if I have a another sibling children element (e.g <destination><dummy>) which was created prior to the xslt running , then this element will be overwritten after the running of xslt?really appreciate and hope to hear your advice.
Thanks
-stephen chai--
April 19, 2006 at 12:05 PM #13369
The index functoid you are using is not needed.
You can just use the equal and value mapping functoids.
This means 2 functoids per condition so:
3 conditions = 6 functoids
8 conditions = 16 functoids
22 conditions = 44 functoidsYou could implement this in an inline XSLT scripting functoid or a custom XSLT and use a <xsl:choose> element.
<xsl:for-each select=\”/source/RepeatingParent\”>
<xsl:choose>
<xsl:when test=\”code=’A’\”>
<codeA><xsl:value-of select=\”value\”/></codeA>
</xsl:when>
<xsl:when test=\”code=’B’\”>
<codeB><xsl:value-of select=\”value\”/></codeB>
</xsl:when>
<xsl:when test=\”code=’C’\”>
<codeC><xsl:value-of select=\”value\”/></codeC>
</xsl:when>
</xsl:choose>
</xsl:for-each>Is there a direct relationship between the value of the <code> node and the node name you are mapping to i.e. you can manipulate the value of <code> to be the node name. Then you may be able to use the Link Properties: [url]http://geekswithblogs.net/benny/archive/2006/02/06/68382.aspx[/url]
-
April 21, 2006 at 2:33 AM #13370
Stephen,
Can you email me your source and destination schemas and sample Xml file and possibly the corresponding output flat file.
-
-
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.