code: public void marshalToDoc(XmlModel model) throws JAXBException {
          Marshaller marshaller = jaxbContext().createMarshaller();
          marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, java.lang.Boolean.TRUE);
          try {
              marshaller.setProperty("com.sun.xml.bind.indentString", "  ");
          } catch (Exception e) {
              LOG.debug("Property not supported: {}", e);
          }
  
          Object value = model.marshalRootElement();
          Document doc = model.getDoc();
          Element docElem = doc.getRootElement();
  
          // JAXB only seems to do nice whitespace/namespace stuff when writing to stream
          // rather than DOM directly
          // marshaller.marshal(value, docElem);
  
          StringWriter buffer = new StringWriter();
          marshaller.marshal(value, buffer);
  
          // now lets parse the XML and insert the root element into the doc
          String xml = buffer.toString();
          if (!model.getNs().equals(springNS)) {
              // !!!
              xml = xml.replaceAll(springNS, model.getNs());
          }
          Document camelDoc = parse(new XMLStringSource(xml));
          Node camelElem = camelDoc.getRootElement();
  
          // TODO
          //val camelElem = doc.importNode(element, true)
  
          if (model.isRoutesContext() && camelDoc.getRootElement().getName().equals("camelContext")) {
              camelDoc.getRootElement().setName("routeContext");
          }
          if (model.isJustRoutes()) {
              replaceChild(doc, camelElem, docElem);
          } else {
              if (model.getNode() != null) {
                  replaceCamelElement(docElem, camelElem, model.getNode());
              } else {
                  docElem.addNode(camelElem);
              }
          }
      }
docs: Marshals the model to XML and updates the model's doc property to contain the
  new marshalled model
  
  @param model