title: XSLT: help me fix multiple BODY tags
body: <p>I need to postprocess some HTML that has bad structure -- e.g.</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;...&lt;/body&gt;
  &lt;body&gt;...&lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What's the best way to transform this HTML so that the contents of the second body appear inside the first, except of course the extra body tag? I don't want to manipulate anything else with this rule.</p>
  
  <p>I've thought of matching on the html tag and handling it from there using explicit apply-templates calls, but it seems a little sloppy to me. I know how to match the spurious bodies ("body[position() > 1]") but I'd like some ideas on how best to write the transform.</p>
  
  <p>Edit: I do need to apply other templates to children of all of these elements, so a simple copy won't work.</p>
  
  <p>And I would like to preserve comments and processing instructions. I want pretty much the entire document as an identity transform, except for these multiple bodies and some other minor edits, which I am already doing successfully.</p>
  
  <p>Edit 2: It is important to keep the children of the second body element in the above example. They should be children of the first body tag in the output, at the end of the child nodes of the first body tag.</p>
  
  <p>Edit 3: Here is some illustrative input/output (not checked for validity):</p>
  
  <pre><code>&lt;html&gt;
    &lt;!-- Look at my comments --&gt;
    &lt;head&gt;
      &lt;title&gt;My title!&lt;/title&gt;
      &lt;!-- Commentary --&gt;
    &lt;/head&gt;
    &lt;body&gt;
       &lt;p&gt;Something &lt;b&gt;bold&lt;/b&gt;&lt;/p&gt;
    &lt;/body&gt;
    &lt;body&gt;
       &lt;!-- heh --&gt;
       &lt;p&gt;Some bozo put my parent in here.&lt;/p&gt;
    &lt;/body&gt;
    &lt;body&gt;
       &lt;p&gt;More stuff here&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>needs to be:</p>
  
  <pre><code>&lt;html&gt;
    &lt;!-- Look at my comments --&gt;
    &lt;head&gt;
      &lt;title&gt;My title!&lt;/title&gt;
      &lt;!-- Commentary --&gt;
    &lt;/head&gt;
    &lt;body&gt;
       &lt;p&gt;Something &lt;b&gt;bold&lt;/b&gt;&lt;/p&gt;
       &lt;!-- heh --&gt;
       &lt;p&gt;Some bozo put my parent in here.&lt;/p&gt;
       &lt;p&gt;More stuff here&lt;/p&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>