Discussion:
Record Count for the inner loop in mapping
(too old to reply)
g***@gmail.com
2005-11-21 16:04:48 UTC
Permalink
Hi
I have a source schema which looks like this
<MyNode>
<record>
<header>
<member1>
<member2>
</record>
<record>
<header>
<member1>
<member2>
<member2>
</record>
<MyNode>

I want to map only the last "<member>" record to destination schema
conditionally. If i take recordcount it gives total number of records
in whole message (in this case 5)
If i use inline XSLT then i cant return the recordcount out of the
script functoid so that i can compare it.
Please help me out to solve this
Samuel L
2005-11-22 08:27:04 UTC
Permalink
Hi!

Could you please explain your acenario a bit further. How will your
destination look like? Will it contain multiple member nodes? And multiple
Record nodes also?

This will make it easier to help you!
Post by g***@gmail.com
Hi
I have a source schema which looks like this
<MyNode>
<record>
<header>
<member1>
<member2>
</record>
<record>
<header>
<member1>
<member2>
<member2>
</record>
<MyNode>
I want to map only the last "<member>" record to destination schema
conditionally. If i take recordcount it gives total number of records
in whole message (in this case 5)
If i use inline XSLT then i cant return the recordcount out of the
script functoid so that i can compare it.
Please help me out to solve this
Gan
2005-11-22 14:56:03 UTC
Permalink
Hi Samuel
Thanks for ur reply.
Actually my source looks like this
<MyNode>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
</record>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
<member3>
<element1/><element2/><element3/>
</member3>
</record>
<MyNode>

Its much more complex than this.
And destination required that the last <member> node to be mapped to a
particular node and all other <member> nodes to be mapped to some other
destination nodes.
So i was thinking if i can find record count for the <member> node under
each <record> node then i can goto last one by comparing the i th record to
record count.
But record count functoid gives total records in the message ( in this case 5)
So i am not able to use it.
Let me know if u understood my problem.
--
Thanks and Regards,
Gan
Post by Samuel L
Hi!
Could you please explain your acenario a bit further. How will your
destination look like? Will it contain multiple member nodes? And multiple
Record nodes also?
This will make it easier to help you!
Post by g***@gmail.com
Hi
I have a source schema which looks like this
<MyNode>
<record>
<header>
<member1>
<member2>
</record>
<record>
<header>
<member1>
<member2>
<member2>
</record>
<MyNode>
I want to map only the last "<member>" record to destination schema
conditionally. If i take recordcount it gives total number of records
in whole message (in this case 5)
If i use inline XSLT then i cant return the recordcount out of the
script functoid so that i can compare it.
Please help me out to solve this
Samuel L
2005-11-22 15:40:04 UTC
Permalink
Well, I don't know if I've understood correctly. But I think that some custom
xslt could help in some way!?! Here is hopefully a good starting point...

<xsl:foreach select="//Record">
<xsl:foreach select="Member">
<xsl:if test="position()=last()">
<!-- add code here for last member -->
</xsl:if>
<xsl:if test="not(position()=last())">
<!-- add code here for other members -->
</xsl:if>
</xsl:foreach>
</xsl:foreach>

Hope this helps in some way! Please let me know of your progress!

Godd luck Gan!
Post by Gan
Hi Samuel
Thanks for ur reply.
Actually my source looks like this
<MyNode>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
</record>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
<member3>
<element1/><element2/><element3/>
</member3>
</record>
<MyNode>
Its much more complex than this.
And destination required that the last <member> node to be mapped to a
particular node and all other <member> nodes to be mapped to some other
destination nodes.
So i was thinking if i can find record count for the <member> node under
each <record> node then i can goto last one by comparing the i th record to
record count.
But record count functoid gives total records in the message ( in this case 5)
So i am not able to use it.
Let me know if u understood my problem.
--
Thanks and Regards,
Gan
Post by Samuel L
Hi!
Could you please explain your acenario a bit further. How will your
destination look like? Will it contain multiple member nodes? And multiple
Record nodes also?
This will make it easier to help you!
Post by g***@gmail.com
Hi
I have a source schema which looks like this
<MyNode>
<record>
<header>
<member1>
<member2>
</record>
<record>
<header>
<member1>
<member2>
<member2>
</record>
<MyNode>
I want to map only the last "<member>" record to destination schema
conditionally. If i take recordcount it gives total number of records
in whole message (in this case 5)
If i use inline XSLT then i cant return the recordcount out of the
script functoid so that i can compare it.
Please help me out to solve this
Gan
2005-11-22 16:16:02 UTC
Permalink
Hi Sam
Thanks for your reply.
U r correct it works in that way. I have tried this.
But there is lot of mapping done depending on this condition
(position()=last())
So in this case i have to add all the mapping xslt code inside inline Xslt
functoid which i dont think is a good idea.
After all mapping is to make things easier rite? ;)
Is there any other way i can get record count out of any type of functoid or
something like that?
Or is it possible to set a global variable inside Inline Xslt functoid and
use it in other functoid?
Kindly let me know if you find out any alternatives..
Thanks again
--
Thanks and Regards,
Gan
Post by Samuel L
Well, I don't know if I've understood correctly. But I think that some custom
xslt could help in some way!?! Here is hopefully a good starting point...
<xsl:foreach select="//Record">
<xsl:foreach select="Member">
<xsl:if test="position()=last()">
<!-- add code here for last member -->
</xsl:if>
<xsl:if test="not(position()=last())">
<!-- add code here for other members -->
</xsl:if>
</xsl:foreach>
</xsl:foreach>
Hope this helps in some way! Please let me know of your progress!
Godd luck Gan!
Post by Gan
Hi Samuel
Thanks for ur reply.
Actually my source looks like this
<MyNode>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
</record>
<record>
<header>
<member1>
<element1/><element2/><element3/>
</member1>
<member2>
<element1/><element2/><element3/>
</member2>
<member3>
<element1/><element2/><element3/>
</member3>
</record>
<MyNode>
Its much more complex than this.
And destination required that the last <member> node to be mapped to a
particular node and all other <member> nodes to be mapped to some other
destination nodes.
So i was thinking if i can find record count for the <member> node under
each <record> node then i can goto last one by comparing the i th record to
record count.
But record count functoid gives total records in the message ( in this case 5)
So i am not able to use it.
Let me know if u understood my problem.
--
Thanks and Regards,
Gan
Post by Samuel L
Hi!
Could you please explain your acenario a bit further. How will your
destination look like? Will it contain multiple member nodes? And multiple
Record nodes also?
This will make it easier to help you!
Post by g***@gmail.com
Hi
I have a source schema which looks like this
<MyNode>
<record>
<header>
<member1>
<member2>
</record>
<record>
<header>
<member1>
<member2>
<member2>
</record>
<MyNode>
I want to map only the last "<member>" record to destination schema
conditionally. If i take recordcount it gives total number of records
in whole message (in this case 5)
If i use inline XSLT then i cant return the recordcount out of the
script functoid so that i can compare it.
Please help me out to solve this
Samuel L
2005-11-22 17:39:07 UTC
Permalink
Hi GAN...

I think I have found a way that might help you!

The following templates returns the last member in the record node with the
index that is sent as input parameter.

<xsl:template name="LastMember">
<xsl:param name="recordIndex" />
<xsl:apply-templates
select="//Record[position()=$recordIndex]/Member[position()=last()]" />
</xsl:template>

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

Add this to a scripting functoid and set the script type to Inline XSLT Call
Template.
Then add an Iterator functoid and connect it between the Record node in your
source schema and the scripting functoid. Then connect the scripting functoid
to the "Last member node" in your destination schema.

So this scripting funtoid only focuses on the last member, so you can do all
other mappings outside the scripting, which is what you wanted! =)

The second template (the identity translation) can of course be changed to
meet your needs!

Hope this is what you wanted!?! Otherwise, please let me know!
Also let me know if there is something here that you don't understand!
Samuel L
2005-11-22 17:50:03 UTC
Permalink
Sorry GAN... I'm probably getting to tired now!! =)
I messed it all up... I misunderstood you!
Post by Gan
But there is lot of mapping done depending on this condition
I think I missed this part!
Post by Gan
Hi GAN...
I think I have found a way that might help you!
The following templates returns the last member in the record node with the
index that is sent as input parameter.
<xsl:template name="LastMember">
<xsl:param name="recordIndex" />
<xsl:apply-templates
select="//Record[position()=$recordIndex]/Member[position()=last()]" />
</xsl:template>
<!-- Identity Translation -->
<xsl:template match="*">
<xsl:copy>
</xsl:copy>
</xsl:template>
Add this to a scripting functoid and set the script type to Inline XSLT Call
Template.
Then add an Iterator functoid and connect it between the Record node in your
source schema and the scripting functoid. Then connect the scripting functoid
to the "Last member node" in your destination schema.
So this scripting funtoid only focuses on the last member, so you can do all
other mappings outside the scripting, which is what you wanted! =)
The second template (the identity translation) can of course be changed to
meet your needs!
Hope this is what you wanted!?! Otherwise, please let me know!
Also let me know if there is something here that you don't understand!
Gan
2005-11-22 19:23:03 UTC
Permalink
Thats alrite Sam...
I apreciate your attention to solve this problem.
Scripting Xslt inline functoid doesnt take any parameter rite?
--
Thanks and Regards,
Gan
Post by Samuel L
Sorry GAN... I'm probably getting to tired now!! =)
I messed it all up... I misunderstood you!
Post by Gan
But there is lot of mapping done depending on this condition
I think I missed this part!
Post by Gan
Hi GAN...
I think I have found a way that might help you!
The following templates returns the last member in the record node with the
index that is sent as input parameter.
<xsl:template name="LastMember">
<xsl:param name="recordIndex" />
<xsl:apply-templates
select="//Record[position()=$recordIndex]/Member[position()=last()]" />
</xsl:template>
<!-- Identity Translation -->
<xsl:template match="*">
<xsl:copy>
</xsl:copy>
</xsl:template>
Add this to a scripting functoid and set the script type to Inline XSLT Call
Template.
Then add an Iterator functoid and connect it between the Record node in your
source schema and the scripting functoid. Then connect the scripting functoid
to the "Last member node" in your destination schema.
So this scripting funtoid only focuses on the last member, so you can do all
other mappings outside the scripting, which is what you wanted! =)
The second template (the identity translation) can of course be changed to
meet your needs!
Hope this is what you wanted!?! Otherwise, please let me know!
Also let me know if there is something here that you don't understand!
Samuel L
2005-11-23 08:32:06 UTC
Permalink
Gan,

Have you come up with any solution?
Now - when I think I understand the problem!! - it seems to be a very tricky
situation you've got there!

Seems almost impossible to do in this version of BizTalk mapper. Do you agree?

Maybe you've already thought of this idea, but a very non-optimal solution
would be to create a new schema by just extending your old source schema with
an attribute in the Record-node, holding the value of the member count for
each record node.

Then you could just create a map that just mass copies the whole schema, and
then adds the member count value to each record node. Then you should be able
to create your desired map.

Though it is a quite bad solution, it might work if nothing else does.

Please let me know of your progress!
Post by Gan
Thats alrite Sam...
I apreciate your attention to solve this problem.
Scripting Xslt inline functoid doesnt take any parameter rite?
--
Thanks and Regards,
Gan
Post by Samuel L
Sorry GAN... I'm probably getting to tired now!! =)
I messed it all up... I misunderstood you!
Post by Gan
But there is lot of mapping done depending on this condition
I think I missed this part!
Post by Gan
Hi GAN...
I think I have found a way that might help you!
The following templates returns the last member in the record node with the
index that is sent as input parameter.
<xsl:template name="LastMember">
<xsl:param name="recordIndex" />
<xsl:apply-templates
select="//Record[position()=$recordIndex]/Member[position()=last()]" />
</xsl:template>
<!-- Identity Translation -->
<xsl:template match="*">
<xsl:copy>
</xsl:copy>
</xsl:template>
Add this to a scripting functoid and set the script type to Inline XSLT Call
Template.
Then add an Iterator functoid and connect it between the Record node in your
source schema and the scripting functoid. Then connect the scripting functoid
to the "Last member node" in your destination schema.
So this scripting funtoid only focuses on the last member, so you can do all
other mappings outside the scripting, which is what you wanted! =)
The second template (the identity translation) can of course be changed to
meet your needs!
Hope this is what you wanted!?! Otherwise, please let me know!
Also let me know if there is something here that you don't understand!
Samuel L
2005-12-02 14:31:01 UTC
Permalink
Hi Gan...

Just wondering if you came up with a solution for your this task!?!
Please let me know whether you did or not... I'm really curious about this!

// samuel L
Gan
2005-12-02 14:37:03 UTC
Permalink
Hi Sam,
I did solve the problem. But it was indirectly depending on my data.
There was a sequence in those repeating records like 1,2,3...
i used that to find the maximum using cumulative maximum functoid and thus i
could separate last record and other records.
--
Thanks and Regards,
Gan
Post by Samuel L
Hi Gan...
Just wondering if you came up with a solution for your this task!?!
Please let me know whether you did or not... I'm really curious about this!
// samuel L
Loading...