This weekend I needed to adjust my interval workout while it was in progress (yes, I needed a break!) This resulted in me having two different activities and two TCX files for each.
I searched and downloaded various software, but they didn't do exactly what I wanted. (Some didn't preserve the calories, and some turned the workout into a course, etc)
I then tried just copying all the laps from one TCX to the other using notepad, but that didn't work either. The distance was corrupt when I uploaded to Garmin Connect. I realized that the the individual laps in each activity have a cumulative distance tracker. So all I needed to do to make this work is offset the last distance tracked to all of the distances from the other activity.
I created a simple XSLT transform that can be applied to two TCX files and it will create a new merged activity.
Thought I'd share.
(Note, you'll need a XSLT processor like saxon/xalan or others)