BizTalk Server General - Looping problem

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > December 2005 > Looping problem





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 Looping problem
Niclas

2005-12-19, 5:54 pm

Hello,

I have a problem wich probably has an easy sloution(or at least should have).
What I want to do is to loop from one record in the source document into
many records in the destination record.

Here's an example:

<Source doc>
<sum>
<grand_total>
<total>
<charges>
</sum>
</Source doc>

Into

<Destination doc>
<sum>
<grand_total>
</sum>
<sum>
<total>
</sum>
<sum>
<charges>
</sum>
</Destination doc>

Grateful for help!

Thanks
Niclas
Samuel L

2005-12-19, 5:54 pm

Hej Niclas!

I don't know the exact problem scenario, but here is a solution that might
work (depending on your scenario).

If you are able to modify the destination schema, then you could set it to
contain a record with name "sum" and the 'max occurences' property set to 3
(or unbounded if you want). Then place a 'choice group' inside this record.
The choice group then contains the different field elements (grand_total,
total and charges).

If it's the case that you are not allowed to modify the destination schema,
then this can be done using some custom XSLT.

Hope this helps you in some way! Please let me know of your progress and if
you need some more help!


"Niclas" wrote:

> Hello,
>
> I have a problem wich probably has an easy sloution(or at least should have).
> What I want to do is to loop from one record in the source document into
> many records in the destination record.
>
> Here's an example:
>
> <Source doc>
> <sum>
> <grand_total>
> <total>
> <charges>
> </sum>
> </Source doc>
>
> Into
>
> <Destination doc>
> <sum>
> <grand_total>
> </sum>
> <sum>
> <total>
> </sum>
> <sum>
> <charges>
> </sum>
> </Destination doc>
>
> Grateful for help!
>
> Thanks
> Niclas

Niclas

2005-12-20, 7:59 am

Hi Samuel,

Thanks for your input.
I am able to make changes to the schema, but I'm not sure I understand how
adding a choice-group will help. Could you explain further?

Thanks alot.

Niclas

"Samuel L" wrote:
[vbcol=seagreen]
> Hej Niclas!
>
> I don't know the exact problem scenario, but here is a solution that might
> work (depending on your scenario).
>
> If you are able to modify the destination schema, then you could set it to
> contain a record with name "sum" and the 'max occurences' property set to 3
> (or unbounded if you want). Then place a 'choice group' inside this record.
> The choice group then contains the different field elements (grand_total,
> total and charges).
>
> If it's the case that you are not allowed to modify the destination schema,
> then this can be done using some custom XSLT.
>
> Hope this helps you in some way! Please let me know of your progress and if
> you need some more help!
>
>
> "Niclas" wrote:
>
Samuel L

2005-12-20, 5:54 pm

Ok, sorry.. maybe I misinterpreted your problem.

How is your destination schema defined?
Intuitevly a choice group would enable the desired destination schema
structure. But the thing is that the BizTalk mapper is not able to separate
the input fields into several destination records. So this did actually not
achieve anything.

Anyway, this can be done in a variety of ways using some custom XSLT.
I will give you two suggestions of how to do it in the following postings.

Sorry for confusing you, but hope this helps you!


"Niclas" wrote:
[vbcol=seagreen]
> Hi Samuel,
>
> Thanks for your input.
> I am able to make changes to the schema, but I'm not sure I understand how
> adding a choice-group will help. Could you explain further?
>
> Thanks alot.
>
> Niclas
>
> "Samuel L" wrote:
>
Samuel L

2005-12-20, 5:54 pm

Suggestion 1
=============================

1) Insert a scripting functoid
2) Connect the three fields in the source to the scripting functoid
3) Connect the scripting functoid to the sum-node in the destination schema
4) Use the following custom inline xslt code in the scripting functoid:

<xsl:template name="MyXsltTemplate">
<xsl:param name="grandTotal" />
<xsl:param name="total" />
<xsl:param name="charges" />

<sum>
<xsl:element name="grand_total">
<xsl:value-of select="$grandTotal" />
</xsl:element>
</sum>

<sum>
<xsl:element name="total">
<xsl:value-of select="$total" />
</xsl:element>
</sum>

<sum>
<xsl:element name="charges">
<xsl:value-of select="$charges" />
</xsl:element>
</sum>

</xsl:template>

This should be it!
Let me know if there is something you don't get here!

Samuel L

2005-12-20, 5:54 pm

In step 4 I meant "Inline XSLT Call template" code!

Sorry about that!


"Samuel L" wrote:

> Suggestion 1
> =============================
>
> 1) Insert a scripting functoid
> 2) Connect the three fields in the source to the scripting functoid
> 3) Connect the scripting functoid to the sum-node in the destination schema
> 4) Use the following custom inline xslt code in the scripting functoid:
>
> <xsl:template name="MyXsltTemplate">
> <xsl:param name="grandTotal" />
> <xsl:param name="total" />
> <xsl:param name="charges" />
>
> <sum>
> <xsl:element name="grand_total">
> <xsl:value-of select="$grandTotal" />
> </xsl:element>
> </sum>
>
> <sum>
> <xsl:element name="total">
> <xsl:value-of select="$total" />
> </xsl:element>
> </sum>
>
> <sum>
> <xsl:element name="charges">
> <xsl:value-of select="$charges" />
> </xsl:element>
> </sum>
>
> </xsl:template>
>
> This should be it!
> Let me know if there is something you don't get here!
>

Samuel L

2005-12-20, 5:54 pm

Suggestion 2
=======================

1) Use a scripting functoid without any input
2) Connect it to the sum-node in the dest schema
3) Use the following Inline XSLT Call template code in the functoid:

<xsl:template name="MyXsltTemplate">
<xsl:for-each select="/child::*/child::*/child::*">
<sum>
<xsl:apply-templates select="current()" />
</sum>
</xsl:for-each>
</xsl:template>

<xsl:template match="*">
<xsl:copy >
<xsl:apply-templates select="* | node()"/>
</xsl:copy>
</xsl:template>

Niclas

2005-12-20, 5:54 pm

THANKS ALOT!!!

I went with suggestion 1 and it worked perfect. Pretty simple once you know
how to do it :-).

Once again, thank you for your help.

Niclas

"Samuel L" wrote:

> Suggestion 2
> =======================
>
> 1) Use a scripting functoid without any input
> 2) Connect it to the sum-node in the dest schema
> 3) Use the following Inline XSLT Call template code in the functoid:
>
> <xsl:template name="MyXsltTemplate">
> <xsl:for-each select="/child::*/child::*/child::*">
> <sum>
> <xsl:apply-templates select="current()" />
> </sum>
> </xsl:for-each>
> </xsl:template>
>
> <xsl:template match="*">
> <xsl:copy >
> <xsl:apply-templates select="* | node()"/>
> </xsl:copy>
> </xsl:template>
>

Samuel L

2005-12-20, 5:54 pm

You're welcome Niclas!

If you are using the web-based technet Discussion Groups browser, could you
please just mark the posting you chose as the correct answer. This is so that
others know that this thread is answered and "closed"... and additionally so
that I get my creds for it! =)


"Niclas" wrote:
[vbcol=seagreen]
> THANKS ALOT!!!
>
> I went with suggestion 1 and it worked perfect. Pretty simple once you know
> how to do it :-).
>
> Once again, thank you for your help.
>
> Niclas
>
> "Samuel L" wrote:
>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com