troubleshooting Question

Would need a solution for this problem either in XSLT or Groovy script

Avatar of kalyangkm
kalyangkmFlag for United States of America asked on
XML* XLST* Groovy
6 Comments3 Solutions19 ViewsLast Modified:

Hi Folks,

I have a hierarchy problem where in the manager hierarchy needs to be shown for an employee upto a level of 5 or the top level/CEO.  So I have user ID and manager ID as Key and Value pairs respectively 

From the following XML input which has the User ID and Manger ID I would need the User ID and the corresponding mangers upto to the top most level or the 5 level and the top most manager/CEO user ID is "1111111". 

Input XML

      <managerId>5555555</managerId>       <userId>1222222</userId>     </EmpJob>     <EmpJob>       <managerId>3333333</managerId>       <userId>4444444</userId>     </EmpJob>     <EmpJob>       <managerId>1111111</managerId>       <userId>42479</userId>     </EmpJob>     <EmpJob>       <managerId>4444444</managerId>       <userId>5555555</userId>     </EmpJob>     <EmpJob>       <managerId>2222222</managerId>       <userId>3333333</userId>     </EmpJob>     <EmpJob>       <managerId>1111111</managerId>       <userId>885247</userId>     </EmpJob>     <EmpJob>       <managerId>1111111</managerId>       <userId>2222222</userId>     </EmpJob>     <EmpJob>       <managerId>1111111</managerId>       <userId>885311</userId>     </EmpJob>     <EmpJob>       <managerId>2222222</managerId>       <userId>885325</userId>     </EmpJob> <EmpJob>

Open in new window

Desired output XML

      <userId>1222222</userId>       <mangerLvl1>1111111</mangerLvl1>      <mangerLvl2>2222222</mangerLvl2>      <mangerLvl3>3333333</mangerLvl3>      <mangerLvl4>4444444</mangerLvl4>      <mangerLvl5>5555555</mangerLvl5>     </EmpJob>     <EmpJob>       <userId>4444444</userId>       <mangerLvl1>1111111</mangerLvl1>      <mangerLvl2>2222222</mangerLvl2>      <mangerLvl3>3333333</mangerLvl3>     </EmpJob>     <EmpJob>       <userId>42479</userId>       <mangerLvl1>1111111</mangerLvl1>     </EmpJob>     <EmpJob>       <userId>5555555</userId>       <mangerLvl1>1111111</mangerLvl1>      <mangerLvl2>2222222</mangerLvl2>      <mangerLvl3>3333333</mangerLvl3>      <mangerLvl4>4444444</mangerLvl4>     </EmpJob>     <EmpJob>       <userId>3333333</userId>       <mangerLvl1>1111111</mangerLvl1>      <mangerLvl2>2222222</mangerLvl2>     </EmpJob>     <EmpJob>       <userId>885247</userId>       <mangerLvl1>1111111</mangerLvl1>     </EmpJob>     <EmpJob>       <userId>2222222</userId>       <mangerLvl1>1111111</mangerLvl1>     </EmpJob>     <EmpJob>       <userId>885311</userId>       <mangerLvl1>1111111</mangerLvl1>     </EmpJob>     <EmpJob>       <userId>885325</userId>       <mangerLvl1>1111111</mangerLvl1>      <mangerLvl2>2222222</mangerLvl2>     </EmpJob> <EmpJob>

Open in new window

Gertone (Geert Bormans)
Information Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 3 Answers and 6 Comments.
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>


Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 3 Answers and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004