Grouping XML Messages using custom XSLT- BizTalk 2010


Thought of writing this post after seeing multiple questions being asked about it on MSDN Forums


Scenario: We receive Xml message which has details spread across multiple nodes and we want to Consolidate/Group the related details to single node.


Input:







Output:



What we need to achieve this:

We need a map and in map we use custom XSLT.





No mapping/link is  visible on the mapping grid as its done in background  by XSLT which we provide.
We can do linking even after providing custom XSLT with no errors but the output will be based on the XSLT and not linking.
To tell map to apply XSLT we need to set a property Custom XSLT Path to the location where we have our XSLT.



Now lets have a look at the XSLT which we will apply here.


Grouping is done with the  help of key function  and generateId  function. It is also referred as Muenchian method.

In it we group all the Item records coming as an individual but having same Order Id.

In xslt we first create a key and initialize it, which holds the uniqueId which is generated and based on incoming first OrderID.

<xsl:key use="OrderID" match="/s0:Orders/Order1/Order" name="groups"/>

 And we compare this with the rest of the OrderId from incoming message .

<xsl:for-each select="Order1/Order[generate-id(.)=generate-id(key('groups',OrderID))]">

If match found then an output node is created with  Item records  having same OrderID. This will group all the items which belong to the same order.


<xsl:for-each select="key('groups',OrderID)">

If not then new uniqueId is created for that node  and again checked through all the incoming nodes.


Download sample 


Grouping XML using custom XSLT

Will keep on posting as an when I find something to share!!!!!!!!!!!!


Related Post 

  • BizTalk Server: Multiple XML files to Single FlatFile Using File Adapter
  • BizTalk 2013: Inserting RawXML (Whole Incoming XML Message) in SQL database
  • BizTalk 2013: Inserting RawXML (Whole Incoming XML Message) in SQL database - Part 2
  • Is it possible to have Map Chaining on the Port Level
  • Promoting custom context property using Pipeline Component
  • Custom ZipReceivePipeline to Unzip Multi-Type Messages
  • Grouping and debatching Inbound Messages from WCF SQL Adapter - BizTalk 2010
  • Polling data from SQL using WCF-SQL Adapter in BizTalk 2010 - TypedPolling(From Multiple table)
  • Grouping XML Messages using custom XSLT- BizTalk 2010
  • Insert Records in SQL Server using WCF-SQL Adapter in BizTalk 2010 - Composite operation(Multiple Records insertion)
  • Insert Records in SQL Server using WCF-SQL Adapter in BizTalk 2010- Composite Operation (Message Transformation Pattern)
  • Debatching(Splitting) XML Message - BizTalk 2010
  • Debatching(Splitting) XML Message in Orches07ation using DefaultPipeline - BizTalk 2010

  • ServerLess360



    Comments

    Popular posts from this blog

    The request has both SAS authentication scheme and 'Bearer' authorization scheme. Only one scheme should be used

    Getting Started with Logic Apps - AS2

    How to Debug and Trace request in Azure APIM - Portal, Postman, RequestBin