I am trying to add one element from some XML to certain children elements in the same XML. The element in question is repeated already so the value has to be from the correct section of the XML. Here is the source XML:
<Extract>
<Packet>
<TXREQUESTID>694154</TXREQUESTID>
<Data>
<Property>
<Key>phoneNumber</Key>
</Property>
<Property>
<Key>ownerName</Key>
</Property>
</Data>
<Milestones>
<Milestone>
<Code>123123</Code>
</Milestone>
<Milestone>
<Code>123125</Code>
</Milestone>
</Milestones>
</Packet>
<Packet>
<TXREQUESTID>694155</TXREQUESTID>
<Data>
<Property>
<Key>phoneNumber</Key>
</Property>
<Property>
<Key>ownerName</Key>
</Property>
</Data>
<Milestones>
<Milestone>
<Code>789789</Code>
</Milestone>
<Milestone>
<Code>123126</Code>
</Milestone>
</Milestones>
</Packet>
</Extract>
I need to replicate the TXREQUESTID element as an element in the child Property and Milestone elements. When finished it needs to look like this:
<Extract>
<Packet>
<TXREQUESTID>694154</TXREQUESTID>
<Data>
<Property>
<Key>phoneNumber</Key>
<TXREQUESTID>694154</TXREQUESTID>
</Property>
<Property>
<Key>ownerName</Key>
<TXREQUESTID>694154</TXREQUESTID>
</Property>
</Data>
<Milestones>
<Milestone>
<Code>123123</Code>
<TXREQUESTID>694154</TXREQUESTID>
</Milestone>
<Milestone>
<Code>123125</Code>
<TXREQUESTID>694154</TXREQUESTID>
</Milestone>
</Milestones>
</Packet>
<Packet>
<TXREQUESTID>694155</TXREQUESTID>
<Data>
<Property>
<Key>phoneNumber</Key>
<TXREQUESTID>694155</TXREQUESTID>
</Property>
<Property>
<Key>ownerName</Key>
<TXREQUESTID>694155</TXREQUESTID>
</Property>
</Data>
<Milestones>
<Milestone>
<Code>789789</Code>
<TXREQUESTID>694155</TXREQUESTID>
</Milestone>
<Milestone>
<Code>123126</Code>
<TXREQUESTID>694155</TXREQUESTID>
</Milestone>
</Milestones>
</Packet>
</Extract>
I've spent hours on this and haven't had any luck. This seems like it should be simple but I'm finding the XSLT syntax baffling. Can anyone point me in the right direction?