@Override
  public void parse(InputSource input) throws SAXException {
    Assert.assertTrue(handler != null);

    boolean isClientCache = creation instanceof ClientCacheCreation;

    handler.startDocument();

    AttributesImpl atts = new AttributesImpl();
    if (useSchema) {
      if (null == version.getSchemaLocation()) {
        throw new IllegalStateException("No schema for version " + version.getVersion());
      }
      // add schema location for cache schema.
      handler.startPrefixMapping(W3C_XML_SCHEMA_INSTANCE_PREFIX, W3C_XML_SCHEMA_INSTANCE_NS_URI);
      addAttribute(atts, W3C_XML_SCHEMA_INSTANCE_PREFIX,
          W3C_XML_SCHEMA_INSTANCE_ATTRIBUTE_SCHEMA_LOCATION,
          version.getNamespace() + " " + version.getSchemaLocation());

      // add cache schema to default prefix.
      handler.startPrefixMapping(XmlConstants.DEFAULT_PREFIX, version.getNamespace());
      addAttribute(atts, VERSION, version.getVersion());
    }

    // Don't generate XML for attributes that are not set.

    if (creation.hasLockLease()) {
      atts.addAttribute("", "", LOCK_LEASE, "", String.valueOf(creation.getLockLease()));
    }
    if (creation.hasLockTimeout()) {
      atts.addAttribute("", "", LOCK_TIMEOUT, "", String.valueOf(creation.getLockTimeout()));
    }
    if (creation.hasSearchTimeout()) {
      atts.addAttribute("", "", SEARCH_TIMEOUT, "", String.valueOf(creation.getSearchTimeout()));
    }
    if (version.compareTo(CacheXmlVersion.GEMFIRE_5_1) >= 0) {
      if (creation.hasMessageSyncInterval()) {
        atts.addAttribute("", "", MESSAGE_SYNC_INTERVAL, "",
            String.valueOf(creation.getMessageSyncInterval()));
      }
    }
    if (version.compareTo(CacheXmlVersion.GEMFIRE_4_0) >= 0) {
      if (creation.hasServer()) {
        atts.addAttribute("", "", IS_SERVER, "", String.valueOf(creation.isServer()));
      }
      if (creation.hasCopyOnRead()) {
        atts.addAttribute("", "", COPY_ON_READ, "", String.valueOf(creation.getCopyOnRead()));
      }
    }
    if (isClientCache) {
      handler.startElement("", CLIENT_CACHE, CLIENT_CACHE, atts);
    } else {
      handler.startElement("", CACHE, CACHE, atts);
    }
    if (cache != null) {
      if (!isClientCache) {
        generate(cache.getCacheTransactionManager());
      } else if (version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
        generate(cache.getCacheTransactionManager());
      }

      generateDynamicRegionFactory(cache);

      if (!isClientCache) {
        if (version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
          Set<GatewaySender> senderSet = cache.getGatewaySenders();
          for (GatewaySender sender : senderSet) {
            generateGatewaySender(sender);
          }
          generateGatewayReceiver(cache);
          generateAsyncEventQueue(cache);
        }
      }

      if (!isClientCache && version.compareTo(CacheXmlVersion.GEMFIRE_7_0) >= 0) {
        if (cache.getGatewayConflictResolver() != null) {
          generate(GATEWAY_CONFLICT_RESOLVER, cache.getGatewayConflictResolver());
        }
      }

      if (!isClientCache) {
        for (CacheServer bridge : cache.getCacheServers()) {
          generate(bridge);
        }
      }

      if (version.compareTo(CacheXmlVersion.GEMFIRE_5_7) >= 0) {
        Iterator pools;
        if (cache instanceof GemFireCacheImpl) {
          pools = PoolManager.getAll().values().iterator();
        } else {
          pools = creation.getPools().values().iterator();
        }
        while (pools.hasNext()) {
          Pool cp = (Pool) pools.next();
          generate(cp);
        }
      }

      if (version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
        if (cache instanceof GemFireCacheImpl) {
          InternalCache gfc = (InternalCache) cache;
          for (DiskStore ds : gfc.listDiskStores()) {
            generate(ds);
          }
        } else {
          for (DiskStore ds : creation.listDiskStores()) {
            generate(ds);
          }
        }
      }
      if (version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
        generatePdx();
      }

      if (version.compareTo(CacheXmlVersion.GEMFIRE_4_1) >= 0) {
        Map namedAttributes = cache.listRegionAttributes();
        for (Object o : namedAttributes.entrySet()) {
          Map.Entry entry = (Map.Entry) o;
          String id = (String) entry.getKey();
          RegionAttributes attrs = (RegionAttributes) entry.getValue();
          // Since CacheCreation predefines these even in later versions
          // we need to exclude them in all versions.
          // It would be better if CacheCreation could only predefine them
          // for versions 6.5 and later but that is not easy to do
          {
            if (creation instanceof ClientCacheCreation) {
              try {
                ClientRegionShortcut.valueOf(id);
                // skip this client region since id mapped to one of the enum types
                continue;
              } catch (IllegalArgumentException ignore) {
                // id is not a shortcut so go ahead and call generate
              }
            } else {
              try {
                RegionShortcut.valueOf(id);
                // skip this region since id mapped to one of the enum types
                continue;
              } catch (IllegalArgumentException ignore) {
                // id is not a shortcut so go ahead and call generate
              }
            }
          }
          generate(id, attrs);
        }
      }

      if (cache instanceof GemFireCacheImpl) {
        generateRegions();
      } else {
        TreeSet<Region<?, ?>> rSet = new TreeSet<>(new RegionComparator());
        rSet.addAll(cache.rootRegions());
        for (Region<?, ?> region : rSet) {
          generateRegion(region);
        }
      }

      if (version.compareTo(CacheXmlVersion.GEMFIRE_5_8) >= 0) {
        generateFunctionService();
      }
      if (version.compareTo(CacheXmlVersion.GEMFIRE_6_0) >= 0) {
        generateResourceManager();
        generateSerializerRegistration();
      }
      if (!isClientCache) {
        if (version.compareTo(CacheXmlVersion.GEMFIRE_6_5) >= 0) {
          if (cache instanceof GemFireCacheImpl) {
            InternalCache internalCache = (InternalCache) cache;
            for (File file : internalCache.getBackupFiles()) {
              generateBackupFile(file);
            }
          } else {
            for (File file : creation.getBackupFiles()) {
              generateBackupFile(file);
            }
          }
        }
      }
      if (version.compareTo(CacheXmlVersion.GEMFIRE_6_6) >= 0) {
        generateInitializer();
      }
    }

    if (cache instanceof Extensible) {
      @SuppressWarnings("unchecked")
      final Extensible<Cache> extensible = (Extensible<Cache>) cache;
      generate(extensible);
    }

    if (isClientCache) {
      handler.endElement("", CLIENT_CACHE, CLIENT_CACHE);
    } else {
      handler.endElement("", CACHE, CACHE);
    }
    handler.endDocument();
  }
Called by the transformer to parse the "input source". We ignore the input source and, instead,
generate SAX events to the {@link #setContentHandler ContentHandler}.
geode-core/src/main/java/org/apache/geode/internal/cache/xmlcache/CacheXmlGenerator.java