split the incoming data into multiple grouped output records
I have three fields in the source, Student ID, Student name and Student Marks. I need to map the details in the destination, by grouping the data on the basis of marks obtained. Each time there's a new mark , the corresponding details of names and student ID is saved under the a new mark group that is created. how do i come about it when there are n number of new marks?
February 18th, 2015 5:09am

Muenchian grouping  is an options.

But when you mean by grouping the data on the basis of marks obtained., do you mean by group the student details based on the marks like group students who got more than 50 (or x mark) in a group and others in to a group? Gives us the detail and  sample input instances Yes using muenchian grouping  in your map you can achieve grouping.

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 5:19am

Grouping the data on the basis of marks obtained: i need to group the students details based on marks. student name and ID with 100 marks in one grp,  student name and ID with 90 marks in another group. when there is a new mark, a new group needs to be created and filled with the corresponding  student details.
February 18th, 2015 3:00pm

for your scenario i used below xml as input,

<ns0:Students xmlns:ns0="http://BTSTempProj.StudentDetailsIn">
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>10</StudentMarks>
  </Student>
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>20</StudentMarks>
  </Student>
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>10</StudentMarks>
  </Student> 
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>10</StudentMarks>
  </Student>
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>20</StudentMarks>
  </Student>
  <Student>
    <StudentID>StudentID_0</StudentID>
    <StudnetName>StudnetName_0</StudnetName>
    <StudentMarks>30</StudentMarks>
  </Student>   
</ns0:Students>

and here is the output, hope this is what you are looking for. 

<ns0:Students xmlns:ns0="http://BTSTempProj.StudentDetailsOut">
<StudentMarks>10</StudentMarks>
<Student>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
</Student>
<StudentMarks>20</StudentMarks>
<Student>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
</Student>
<StudentMarks>30</StudentMarks>
<Student>
<StudentName>StudnetName_0</StudentName>
<StudentID>StudentID_0</StudentID>
</Student>
</ns0:Students>

Please find the below xslt which you can use, it is basically based on the Muenchian grouping suggested by Ashwin

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:var="http://schemas.microsoft.com/BizTalk/2003/var" exclude-result-prefixes="msxsl var s0" version="1.0" xmlns:ns0="http://BTSTempProj.StudentDetailsOut" xmlns:s0="http://BTSTempProj.StudentDetailsIn">
  <xsl:output omit-xml-declaration="yes" method="xml" version="1.0" />
  <xsl:template match="/">
    <xsl:apply-templates select="/s0:Students" />
  </xsl:template>

  <xsl:key name="groups" match="Student" use="StudentMarks"/>
  <xsl:template match="/s0:Students">
    <ns0:Students>
      <xsl:for-each select="Student[generate-id(.)=generate-id(key('groups',StudentMarks))]">
        <xsl:sort select="StudentMarks" order="ascending"/>
        <StudentMarks>
          <xsl:value-of select="StudentMarks/text()"/>
        </StudentMarks>    
        <Student>    
          <xsl:for-each select="key('groups',StudentMarks)">
            <StudentName>
              <xsl:value-of select="StudnetName/text()"/>
            </StudentName>
            <StudentID>
              <xsl:value-of select="StudentID/text()"/>
            </StudentID> 
            </xsl:for-each>
        </Student>
      </xsl:for-each>        
    </ns0:Students>
  </xsl:template>
</xsl:stylesheet>

Free Windows Admin Tool Kit Click here and download it now
February 18th, 2015 5:54pm

I believe your XSD has a node Student with three child element Student ID, Student name and Student Marks.

You can use looping functoid to do that. 

Student------------------------------ looping Functoid---------------------Destination RootNode For student

    Student name ------------------------Direct Link to destination node--------------->>>>>>>

   Student ID------------------------Direct Link to destination node--------------->>>>>>>

   Student Marks------------------------Direct Link to destination node--------------->>>>>>>

for grouping based on a condition used a equal to functoid source as marks and student destination node equivalent as unbounded node in destination side, you can check the condition for the marks in equal to functoid and it will only map those records which meet the condition.

February 18th, 2015 6:04pm

Thank you Ashwin, Muenchian grouping worked..

Thank you everybody. 

Free Windows Admin Tool Kit Click here and download it now
February 20th, 2015 2:19pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics