0

I am attempting to merge two XML documents (using Pentaho Kettle), and I'm having trouble with my XPATH statement. In the first XML, I have a list of users and their user id's. In the second XML, I have a list of projects, each with an id that corresponds to the user working on it. I am trying to match the two based on the id's. The XPATH statement I'm using is as follows:

//users[user_id='?']/projects

I don't understand why this isn't working. The layout of the XML files is as follows:

<user name="UserOne" user_id="3"><projects/></user>
<user name="UserTwo" user_id="10"><projects/></user>
<project Y="1" name="ProjectOne" user_id="3" />
<project Y="7" name="ProjectTwo" user_id="3" />
<project Y="1" name="ProjectThree" user_id="10" />

The output that I'm looking for is:

<user name="UserOne" user_id="3">
   <projects>
      <project Y="1" name="ProjectOne" user_id="3" />
      <project Y="7" name="ProjectTwo" user_id="3" />
   </projects>
</user>
<user name="UserTwo" user_id="10">
   <projects>      
      <project Y="1" name="ProjectThree" user_id="10" />
   </projects>
</user>

I'm pretty new to all of this, so I won't be surprised if I'm doing something completely wrong. Any help would be appreciated.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by varun0703
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.