Mapping question -- not sure how to approach this one
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > BizTalk Server > BizTalk Server General > Mapping question -- not sure how to approach this one




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Mapping question -- not sure how to approach this one  
cmedin


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-18-06 05:46 AM

OK, here's what I want to do.  Input (not the actual input, but similar
structure):

<Pallet>
<Items>
<Item>
<Reference>0001</Reference>
<Qty>5</Qty>
</Item>
<Item>
<Reference>0001</Reference>
<Qty>5</Qty>
</Item>
<Item>
<Reference>0002</Reference>
<Qty>5</Qty>
</Item>
<Item>
<Reference>0003</Reference>
<Qty>5</Qty>
</Item>
</Items>
</Pallet>
<Pallet>
<Items>
<Item>
<Reference>0001</Reference>
<Qty>5</Qty>
</Item>
<Item>
<Reference>0002</Reference>
<Qty>5</Qty>
</Item>
</Items>
</Pallet>

Now, what I wish to do is map this into the following:
<LineItem>
<Reference>0001</Reference>
<Qty>15</Qty>
</LineItem>
<LineItem>
<Reference>0002/Reference>
<Qty>10/Qty>
</LineItem>
<LineItem>
<Reference>0003/Reference>
<Qty>5</Qty>
</LineItem>

Basically, I want to collect the quantities by Reference and stick into an
output format that has a single Reference segment for each reference #
(0001,0002 etc).  The source can have any number of Item segments
referencing the same #, nested in various Pallets... what I can't figure out
is how to create only one Reference entry on the target side.. I figure that
if I can somehow pull a unique Reference out of the source map I could use
some cumulative functoids together with logical Equal to only sum up the
quantities for the given reference.

But I am lost.. help!


thanks,

Christer







[ Post a follow-up to this message ]



    RE: Mapping question -- not sure how to approach this one  
WenJun Zhang[msft]


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-18-06 05:46 AM

Hi Christer,

The built-in functoids are not good at doing this. I think the most
convenent way is writting custom XPath to query and sum the values either
in the map(script functoid) or in your orchestration.

Thanks.

Best regards,

WenJun Zhang
Microsoft Online Partner Support

This posting is provided "AS IS" with no warranties, and confers no rights.








[ Post a follow-up to this message ]



    Re: Mapping question -- not sure how to approach this one  
Greg Forsythe


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-18-06 05:46 AM

Here is a sample custom Xslt as per WenJun's suggestion

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl" version="1.0"
xmlns:ns0="urn:output">
<xsl:output omit-xml-declaration="yes" version="1.0" method="xml" />
<xsl:key name="itemkey" match="/root//Item" use="Reference"/>
<xsl:template match="/">
<xsl:apply-templates select="/root" />
</xsl:template>
<xsl:template match="/root">
<ns0:root>
<xsl:for-each select="//Item">
<xsl:variable name="group" select="key('itemkey', Reference)"/>
<xsl:if test="generate-id($group[1]) = generate-id()">
<LineItem>
<Reference><xsl:value-of select="Reference" /></Reference>
<Qty><xsl:value-of select="sum($group/Qty)"/></Qty>
</LineItem>
</xsl:if>
</xsl:for-each>
</ns0:root>
</xsl:template>
</xsl:stylesheet>

I gave both your example xml fragments a <root> node and the output schema a
targetnamespace of "urn:output"

Greg


""WenJun Zhang[msft]"" <wjzhang@online.microsoft.com> wrote in message
news:WOPdld6XGHA.5540@TK2MSFTNGXA01.phx.gbl...
> Hi Christer,
>
> The built-in functoids are not good at doing this. I think the most
> convenent way is writting custom XPath to query and sum the values either
> in the map(script functoid) or in your orchestration.
>
> Thanks.
>
> Best regards,
>
> WenJun Zhang
> Microsoft Online Partner Support
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>
>







[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 06:02 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register