BizTalk Server - Combine Multiple Message Instance

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server > June 2007 > Combine Multiple Message Instance





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 Combine Multiple Message Instance
Sandeep

2007-06-09, 1:21 am

Hi,

I have the following inbound XML:

<Addresses>

<Address>
<Customer1>
<Address1>
</Address>

<Address>
<Customer2>
<Address1>
</Address>

<Address>
<Customer1>
<Address2>
</Address>

</Addresses>

The <Address> node will repeat multiple times, for different customers
having multiple adresses.

I would like to convert this into the following:

<AddressInfo>
<Customer1>
<AddressDetails>
<Address1>
<Address2>
</AddressDetails>
</AddressINfo>

<AddressInfo>
<Customer2>
<AddressDetails>
<Address1>
</AddressDetails>
</AddressINfo>

Bascially, i would like to combine all address for the same Customer into a
single node.

Any help or thoughts is greatly appreciated.

Thanks.
Jan Eliasen

2007-06-09, 1:21 am

On Fri, 8 Jun 2007 11:35:01 -0700, Sandeep
<Sandeep@discussions.microsoft.com> wrote:

>Bascially, i would like to combine all address for the same Customer into a
>single node.

Search for the muenchian grouping technique. Use it in an xslt
scripting functoid.

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Sandeep

2007-06-12, 1:19 pm

Thanks Jan. I will go through and give it a try. Thanks again.

"Jan Eliasen" wrote:

> On Fri, 8 Jun 2007 11:35:01 -0700, Sandeep
> <Sandeep@discussions.microsoft.com> wrote:
>
> Search for the muenchian grouping technique. Use it in an xslt
> scripting functoid.
>
> --
> eliasen, representing himself and not the company he works for.
>
> Private blog: http://blog.eliasen.dk
>
> Private email: jan@eliasen.dk
>

Sandeep

2007-06-15, 1:18 am

Jan - one question.

My inbound XML does not use any prefixes - just a default namespace.

I am using the following XSLT, but am unable to generate any data.

<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:export.1.0.xsd"
xmlns:ns0="http://Transform1">
<xsl:output omit-xml-declaration="yes" version="1.0" method="xml" />
<xsl:key name="Custkey" match="/s0:Postings/Posting"
use="PostingUserFirmId"/>
<xsl:template match="/">
<xsl:apply-templates select="/s0:Postings" />
</xsl:template>
<xsl:template match="/s0:Postings">
<ns0:Postings>
<xsl:for-each select="Posting">
<xsl:variable name="group" select="key('Custkey', PostingUserFirmId)"/>
<xsl:if test="generate-id($group[1]) = generate-id()">
<Header>
<PostingUserFirmId>
<xsl:value-of select="PostingUserFirmId" />
</PostingUserFirmId>
<xsl:for-each select="$group">
<Detail>
<TransactionType>
<xsl:value-of select="TransactionType" />
</TransactionType>
<PostingAmount>
<xsl:value-of select="PostingAmount" />
</PostingAmount>
</Detail>
</xsl:for-each>
</Header>
</xsl:if>
</xsl:for-each>
</ns0:Postings>
</xsl:template>
</xsl:stylesheet>

The Inbound XML Looks like

<?xml version="1.0" encoding="UTF-8"?>
<Postings xmlns="urn:export.1.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:export.1.0.xsd">
<Posting>
<TransactionType>ClientCustomRecruitPost</TransactionType>
<PostingType>1001</PostingType>
<PostingAccountType>1</PostingAccountType>
<PostingUserType>2</PostingUserType>
<PostingUserId>159437</PostingUserId>
<PostingUserFirmId>10</PostingUserFirmId>
<PostingDirection>1</PostingDirection>
<PostingAmount>450.55</PostingAmount>
<PostingCreateDate>2007-03-14</PostingCreateDate>
<Notes>This is some notes</Notes>
<ClientTypeId>2</ClientTypeId>
<PracticeArea>3</PracticeArea>
<ProductTypeId>3333</ProductTypeId>
<PaymentId>765549</PaymentId>
</Posting>
</Postings>

If i add the "s0" prefix to my inbound XML, it works fine. But without that,
no data is returned in the output.

Thanks.
Jan Eliasen

2007-06-17, 7:18 pm

On Thu, 14 Jun 2007 15:06:01 -0700, Sandeep
<Sandeep@discussions.microsoft.com> wrote:

>If i add the "s0" prefix to my inbound XML, it works fine. But without that,
>no data is returned in the output.

Try 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:export.1.0.xsd"
xmlns:ns0="http://Transform1">
<xsl:output omit-xml-declaration="yes" version="1.0" method="xml" />
<xsl:key name="Custkey" match="/s0:Postings/s0:Posting"
use="s0:PostingUserFirmId"/>
<xsl:template match="/">
<xsl:apply-templates select="/s0:Postings" />
</xsl:template>
<xsl:template match="/s0:Postings">
<ns0:Postings>
<xsl:for-each select="s0:Posting">
<xsl:variable name="group" select="key('Custkey',
s0:PostingUserFirmId)"/>
<xsl:if test="generate-id($group[1]) = generate-id()">
<Header>
<PostingUserFirmId>
<xsl:value-of select="s0:PostingUserFirmId" />
</PostingUserFirmId>
<xsl:for-each select="$group">
<Detail>
<TransactionType>
<xsl:value-of select="s0:TransactionType" />
</TransactionType>
<PostingAmount>
<xsl:value-of select="s0:PostingAmount" />
</PostingAmount>
</Detail>
</xsl:for-each>
</Header>
</xsl:if>
</xsl:for-each>
</ns0:Postings>
</xsl:template>
</xsl:stylesheet>

--
eliasen, representing himself and not the company he works for.

Private blog: http://blog.eliasen.dk

Private email: jan@eliasen.dk
Sandeep

2007-06-18, 1:22 pm

Thanks Again Jan. It Worked. Thank You.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com