1

Hi I need to convert the following input xml to the below mentioned output xml using xsl 2.0 version. I'm pretty new to xslt and I've tried using apply-templates and for-each-group to get a distinct collection of clients.

Input:

<?xml version="1.0" encoding="utf-8" ?>

<ITEM>
  <allCounselling>
    <ITEM>
      <allAttendingPeople>
        <ITEM>
          <PersonKey>1</PersonKey>
        </ITEM>
      </allAttendingPeople>
      <allSessions>
        <ITEM>
          <KEY></KEY>
          <DATE>12 Dec 2014</DATE>
          <allAttendedPeople>
            <ITEM>
              <PersonKey>1</PersonKey>
            </ITEM>
            <ITEM>
              <PersonKey>2</PersonKey>
            </ITEM>
          </allAttendedPeople>
        </ITEM>
      </allSessions>
    </ITEM>
  </allCounselling>
</ITEM>

Required Output is

<Clients>
  <Client>
    <ClientId>1</ClientId>
  </Client>
  <Client>
    <ClientId>2</ClientId>
  </Client>
</Clients>

The PersonKey value is the ClientId and should be a distinct collection. The other difficult part is that I have to filter the sessions also. If the session Item is within a given date range, then I should only out put the persons within that allAttendedPeople collection of those filtered sessions and then I have to traverse up to get the counselling item which contains those sessions and out put all attending people...I know it's pretty hectic :'( Please help!

rani
  • 23
  • 3
  • Looks like you've not provided the complete example as your problem's description tells a lot, and your expected output just shows the grouping of `PersonKey`. Is the current requirement just to group PersonKeys in the whole document? And please post your tried XSLT here. – Lingamurthy CS Mar 24 '15 at 00:42
  • I will clean up my input xml and xsl and upload soon. Tx for the reply – rani Mar 24 '15 at 01:06
  • Hi I'm running out of time and didn't have time to upload the files. But I managed to get the xsl working. I referred to http://www.dpawson.co.uk/xsl/sect2/N2696.html page to get a distinct collection of all persons. Once the project is over I'll put my xsl file to this question. – rani Mar 24 '15 at 22:31

0 Answers0