code: public static <T> void marshal(String rootName, Collection<T> c, Writer w) throws JAXBException {
      // Create context with generic type
      JAXBContext ctx = JAXBContext.newInstance(findTypes(c));
      Marshaller m = ctx.createMarshaller();
  
      // Create wrapper collection
      JAXBElement element = createCollectionElement(rootName, c);
      m.marshal(element, w);
    }
docs: Convert a collection to a string and sends it to the Writer.
  
  @param rootName Name of the XML root element
  @param c Collection that needs to be marshalled
  @param w Output