Exemple #1
0
 /**
  * Serializes the XML element (including all attributes and subnodes) from the given {@link
  * XMLStreamReader} into a {@link StreamBufferStore}.
  *
  * @param reader cursor must point at a <code>START_ELEMENT</code> event and points at the
  *     corresponding <code>END_ELEMENT</code> event afterwards
  * @return stored document, never <code>null</code>
  * @throws IOException
  * @throws FactoryConfigurationError
  * @throws XMLStreamException
  */
 public static StreamBufferStore serialize(XMLStreamReader reader)
     throws IOException, XMLStreamException, FactoryConfigurationError {
   StreamBufferStore tmpStore = new StreamBufferStore();
   XMLStreamWriter writer = XMLOutputFactory.newInstance().createXMLStreamWriter(tmpStore);
   try {
     copy(writer, reader);
   } finally {
     writer.close();
     tmpStore.close();
   }
   return tmpStore;
 }