code: public void write(String xmlFilename) throws CmsXmlException {
  
          // try to get it from the cache
          Document document = m_cache.get(xmlFilename);
  
          if (document != null) {
              try {
                  CmsXmlUtils.validateXmlStructure(document, CmsEncoder.ENCODING_UTF_8, new CmsXmlEntityResolver(null));
                  OutputStream out = null;
                  out = new FileOutputStream(getFile(xmlFilename));
                  CmsXmlUtils.marshal(document, out, CmsEncoder.ENCODING_UTF_8);
              } catch (FileNotFoundException e) {
                  throw new CmsXmlException(new CmsMessageContainer(null, e.toString()));
              } catch (CmsXmlException e) {
                  // write invalid config files to the file system with a prefix of "invalid-" so they can be inspected for errors
                  try {
                      OutputStream invalidOut = new FileOutputStream(getFile("invalid-" + xmlFilename));
                      CmsXmlUtils.marshal(document, invalidOut, CmsEncoder.ENCODING_UTF_8);
                  } catch (IOException e2) {
                      // ignore
  
                  }
                  throw e;
              }
          }
      }
docs: Writes the given file back to disk.<p>
  
  @param xmlFilename the xml config file (could be relative to the base path)
  
  @throws CmsXmlException if something wrong while writing