code: public static void copy(XMLStreamReader source, XMLStreamWriter sink)
              throws XMLStreamException {
          sink.setNamespaceContext(source.getNamespaceContext());
          // TODO: Make a version of XMLStreamUtils that automatically writes
          // namespace declarations for any namespaces that aren't in it's
          // (new) context yet, but are in the reader's context (currently set
          // above, but it should probably not be...)
          XMLStreamUtils.copy(new BalancedXMLStreamReader(source), sink);
      }
docs: Copies the subtree that the reader is currently position at to the
  given writer. The reader must be positioned at a START_ELEMENT
  event, and when finished, will be positioned on the corresponding
  END_ELEMENT event.
  <p>
  <b>NOTE:</b> Even if successful, this does not currently ensure that
  the output has all used namespaces declared. In particular, if a
  namespace was previously declared in the XML that the reader saw,
  then used within the scope of the elements being copied but no
  re-declared within them, the output will not be self-contained.
  
  @param source the reader whose subtree should be copied.
  @param sink the writer to copy to. It will be left open when finished.
  @throws XMLStreamException if anything goes wrong during the copy.