|
Home > Archive > BizTalk Server Applications Integration > March 2006 > many to one map
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]
|
|
| Daniel 2006-03-21, 8:02 am |
| Hi,
I have what I thought was a very straightforward scenario in BizTalk. I am
getting a flat file that contains plot information, it looks something like
this:
SC1,1,"Daniel"
SC1,2,"Mark"
SC2,3,"Paul"
with the headings:
SiteCode, PlotNumber, Name.
I would like to group the information by sitecode so the following is
produced:
<Sites>
<Site>
<SiteCode>SC1</SiteCode>
<Plots>
<Plot>
<PlotNumber>1</PlotNumber>
<Name>Daniel</Name>
</Plot>
<Plot>
<PlotNumber>2</PlotNumber>
<Name>Mark</Name>
</Plot>
</Plots>
</Site>
<Site>
<SiteCode>SC2</SiteCode>
<Plots>
<Plot>
<PlotNumber>3</PlotNumber>
<Name>Paul</Name>
</Plot>
</Plots>
</Site>
</Sites>
My problem is that I can't seem to figure out how to get the plot
information to "group up" underneath the same sitecode. People have
suggested using a "looping" functoid but I don't think that will work unless
there are multiple records defined in the source docspec. Basically, I want
to "loop" with a "key" value (e.g. loop until <some_value> changes). Is
this possible in the mapper?
Thanks,
Daniel
| |
| Greg Forsythe 2006-03-21, 5:54 pm |
| You need to use a custom XSLT in the map like this:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl s0" version="1.0"
xmlns:s0="urn:your:input:Namespace"
xmlns:ns0="urn:your:output:Namespace">
<xsl:output omit-xml-declaration="yes" version="1.0" method="xml" />
<xsl:key name="sitekey" match="/s0:root/Record" use="SiteCode"/>
<xsl:template match="/">
<xsl:apply-templates select="/s0:root" />
</xsl:template>
<xsl:template match="/s0:root">
<ns0:Sites>
<xsl:for-each select="Record">
<xsl:variable name="group" select="key('sitekey', SiteCode)"/>
<xsl:if test="generate-id($group[1]) = generate-id()">
<Site>
<SiteCode>
<xsl:value-of select="SiteCode" />
</SiteCode>
<Plots>
<xsl:for-each select="$group">
<Plot>
<PlotNumber>
<xsl:value-of select="PlotNumber" />
</PlotNumber>
<Name>
<xsl:value-of select="Name" />
</Name>
</Plot>
</xsl:for-each>
</Plots>
</Site>
</xsl:if>
</xsl:for-each>
</ns0:Sites>
</xsl:template>
</xsl:stylesheet>
There are no functoids that provide <xsl:key> functionality.
Greg
"Daniel" <daniel@nospam.nospam> wrote in message
news:1142944160.46810@ernani.logica.co.uk...
> Hi,
>
> I have what I thought was a very straightforward scenario in BizTalk. I
> am getting a flat file that contains plot information, it looks something
> like this:
>
> SC1,1,"Daniel"
> SC1,2,"Mark"
> SC2,3,"Paul"
>
> with the headings:
>
> SiteCode, PlotNumber, Name.
>
> I would like to group the information by sitecode so the following is
> produced:
>
> <Sites>
> <Site>
> <SiteCode>SC1</SiteCode>
> <Plots>
> <Plot>
> <PlotNumber>1</PlotNumber>
> <Name>Daniel</Name>
> </Plot>
> <Plot>
> <PlotNumber>2</PlotNumber>
> <Name>Mark</Name>
> </Plot>
> </Plots>
> </Site>
> <Site>
> <SiteCode>SC2</SiteCode>
> <Plots>
> <Plot>
> <PlotNumber>3</PlotNumber>
> <Name>Paul</Name>
> </Plot>
> </Plots>
> </Site>
> </Sites>
>
>
> My problem is that I can't seem to figure out how to get the plot
> information to "group up" underneath the same sitecode. People have
> suggested using a "looping" functoid but I don't think that will work
> unless there are multiple records defined in the source docspec.
> Basically, I want to "loop" with a "key" value (e.g. loop until
> <some_value> changes). Is this possible in the mapper?
>
> Thanks,
>
> Daniel
>
| |
| WenJun Zhang[msft] 2006-03-25, 11:37 am |
| Yes, we haven't provided available funtoids to implement such kind of
'group by' function. You should use custom XSLT in script functoid to
combine the records.
Thanks.
Best regards,
WenJun Zhang
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
This posting is provided "AS IS" with no warranties, and confers no rights.
| |
| Daniel 2006-03-25, 11:37 am |
| Thanks for that, I've got it working now.
Daniel
"Greg Forsythe" <greg.forsythe@gmail.com> wrote in message
news:O94xDuRTGHA.5728@tk2msftngp13.phx.gbl...
> You need to use a custom XSLT in the map like this:
>
> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:msxsl="urn:schemas-microsoft-com:xslt"
> exclude-result-prefixes="msxsl s0" version="1.0"
> xmlns:s0="urn:your:input:Namespace"
> xmlns:ns0="urn:your:output:Namespace">
> <xsl:output omit-xml-declaration="yes" version="1.0" method="xml" />
> <xsl:key name="sitekey" match="/s0:root/Record" use="SiteCode"/>
> <xsl:template match="/">
> <xsl:apply-templates select="/s0:root" />
> </xsl:template>
> <xsl:template match="/s0:root">
> <ns0:Sites>
> <xsl:for-each select="Record">
> <xsl:variable name="group" select="key('sitekey', SiteCode)"/>
> <xsl:if test="generate-id($group[1]) = generate-id()">
> <Site>
> <SiteCode>
> <xsl:value-of select="SiteCode" />
> </SiteCode>
> <Plots>
> <xsl:for-each select="$group">
> <Plot>
> <PlotNumber>
> <xsl:value-of select="PlotNumber" />
> </PlotNumber>
> <Name>
> <xsl:value-of select="Name" />
> </Name>
> </Plot>
> </xsl:for-each>
> </Plots>
> </Site>
> </xsl:if>
> </xsl:for-each>
> </ns0:Sites>
> </xsl:template>
> </xsl:stylesheet>
>
> There are no functoids that provide <xsl:key> functionality.
>
> Greg
>
>
> "Daniel" <daniel@nospam.nospam> wrote in message
> news:1142944160.46810@ernani.logica.co.uk...
>
>
|
|
|
|
|