I'm having pretty significant trouble figuring out how to convert a flat XML into a hierarchical result using an XSLT V1 transform. I would post my XSLT, but I'm not sure I'm even approaching it correctly. I know I need to create and use Keys, but, regardless of attempting to apply every example I've found here and elsewhere (many, many, many...), it simply doesn't work.
Here is the input:
<env:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<tns:getClientRS xmlns:tns="http://services.xxx.com/ClientService">
<tns:Acknowledgement>Process completed successfully.</tns:Acknowledgement>
<tns:client>
<tns:ClientID>515164</tns:ClientID>
<tns:episodeID>1</tns:episodeID>
<tns:guarantorID>1</tns:guarantorID>
</tns:client>
<tns:client>
<tns:ClientID>515164</tns:ClientID>
<tns:episodeID>1</tns:episodeID>
<tns:guarantorID>2</tns:guarantorID>
</tns:client>
<tns:plan>
<tns:ClientID>515164</tns:ClientID>
<tns:episodeID>1</tns:episodeID>
<tns:guarantorID>1</tns:guarantorID>
<tns:guarantorPlan>1</tns:guarantorPlan>
</tns:plan>
<tns:plan>
<tns:ClientID>515164</tns:ClientID>
<tns:episodeID>1</tns:episodeID>
<tns:guarantorID>2</tns:guarantorID>
<tns:guarantorPlan>2</tns:guarantorPlan>
</tns:plan>
</tns:getClientRS>
</env:Body>
</env:Envelope>
and desired response XML:
<env:Envelope xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<tns:getClientRS xmlns:tns="http://services.xxx.com/ClientService">
<tns:Acknowledgement>Process completed successfully.</tns:Acknowledgement>
<tns:clients>
<tns:ClientID>515164</tns:ClientID>
<tns:episodes>
<tns:Episode>
<tns:episodeID>1</tns:episodeID>
<tns:Guarantors>
<tns:Guarantor>
<tns:guarantorID>1</tns:guarantorID>
<tns:Plan>
<tns:guarantorPlan>1</tns:guarantorPlan>
</tns:Plan>
</tns:Guarantor>
<tns:Guarantor>
<tns:guarantorID>2</tns:guarantorID>
<tns:Plan>
<tns:guarantorPlan>2</tns:guarantorPlan>
</tns:Plan>
</tns:Guarantor>
</tns:Guarantors>
</tns:Episode>
</tns:episodes>
</tns:clients>
</tns:getClientRS>
</env:Body>
</env:Envelope>
Just trying to keep things simple, but there could be multiple clients and multiple episodes. I suspect that if I can figure out the guarantors, I can figure out the episodes and clients.
I really need help here. No matter what I do, I get only the first of each key... that is, guarantor 1 and plan 1. That's it.