I'm trying to think of a way to translate this input, to the output below:

Input:
<test>
   <foo name="a">
      <wahoo>A</wahoo>
   </foo>
   <foo name="b">
      <wahoo>B</wahoo>
   </foo>
   <foo name="c">
      <wahoo>C</wahoo>
   </foo>
   <group>
      <bar ref="b"/>
      <bar ref="a"/>
   </group>
</test>

Output:
<test>
   <group>
      <wahoo>B</wahoo>
      <wahoo>A</wahoo>
   </group>
</test>

That is, anywhere there is a 'bar', replace it with the contents of the 'foo' it references.  I'm having a difficult time representing this with HXT's Arrow API because the value of the 'ref' attribute is the output of an arrow, but I need it to be just a plain string so that I could use it as an input parameter to the 'hasAttrValue' function.  A similar problem, using 'processTopDown', once I traverse to a 'bar' node, I need to then traverse the root again to find the 'foo', but I'm in the context of the 'bar' node, not the root.

My ears are open to solutions with HaXML or Scrap Your XML-plate, or anything else.

Thanks,
Greg