cancel
Showing results for 
Search instead for 
Did you mean: 

XSLT : Distinct Values Count and Co-relation

SS15
Participant
0 Kudos
359

Hello Experts,

I am using XPath in Repeater with conditions to get an filtered output based on few multiple initial conditions.

On this Repeater Output, I'd like to know the distinct Count of how many nodes have the same value of a child node and display the same data again with count and relation list in XML format (using XSLT variables if feasible).

I am getting count using DistinctValueExtractor Action block however I am looking for XSLT for less execution time and better processing.

Otherwise, if there is some efficient approach to handle this in BLS,then kindly let me know. Thank you.

Sample XML Data - 1
<?xml version="1.0" encoding="UTF-8"?>
<Rowsets>
<Rowset>
<Row>
    <ID>10</ID>
    <Student>A</Student>
    <Subject>English</Subject>
</Row>
 <Row>
    <ID>20</ID>
    <Student>B</Student>
    <Subject>Maths</Subject>
 </Row>
 </Rowset>
</Rowsets>

EXPECTED OUTPUT : DISTINCT COUNT - STUDENT : 2  SUBJECT : 2  
                  SET RELATION : A - English B- Maths

Expected OUTPUT XML : 

<?xml version="1.0" encoding="UTF-8"?>
<Rowsets>
<Rowset>
<Row>
    <ID>10</ID>
    <Student>A</Student>
    <Subject>English</Subject>
</Row>
 <Row>
    <ID>20</ID>
    <Student>B</Student>
    <Subject>Maths</Subject>
 </Row>

<ID>CalcData</ID>
<DistinctStudentCount> 2 </DistinctStudentCount>
<DistinctSubjectCount> 2 </DistinctSubjectCount>
<Total_Student>A,B</Total_Student>
<Total_Subject>English,Maths</Total_Subject>
 </Rowset>
</Rowsets>

Sample XML Data -2 

<?xml version="1.0" encoding="UTF-8"?>
<Rowsets>
<Rowset>
<Row>
    <ID>30</ID>
    <Student>B</Student>
    <Subject>Science</Subject>
 </Row>
<Row>
    <ID>40</ID>
    <Student>B</Student>
    <Subject>Social Studies</Subject>
 </Row>
    </Rowset>
</Rowsets>

EXPECTED OUTPUT :  STUDENT : 1  SUBJECT : 2
                   SET RELATION : B- Science, Social Studies

I checked standard distinct count function however I also need this co-relation along with count in the output xml to be used ahead for Trx processing.

I am a novice when it comes to xslt and i did go through a lot of blogs on grouping, xsl key method however couldn't crack this correctly. Please share code snippet.

Kindly share your insights and solution on above scenario. Thank you.

Accepted Solutions (0)

Answers (0)