private void generateRegions() throws SAXException {
    Set<Region<?, ?>> colocatedChildRegions = new HashSet<>();
    Set<Region> generatedRegions = new HashSet<>();

    // Merge from persist_Nov10 - iterate the regions in order for persistent recovery.
    TreeSet<Region<?, ?>> rSet = new TreeSet<>(new RegionComparator());
    rSet.addAll(cache.rootRegions());
    for (Region<?, ?> root : rSet) {
      Assert.assertTrue(root instanceof LocalRegion);
      if (root instanceof PartitionedRegion) {
        PartitionedRegion pr = (PartitionedRegion) root;
        if (pr.getColocatedWith() != null) {
          colocatedChildRegions.add(root);
        } else {
          generateRegion(root); // normal PR or root in colocated chain
          generatedRegions.add(root);
        }
      } else {
        // normal non pr regions, but they can have PR as subregions
        boolean found = false;
        for (Region<?, ?> subregion : root.subregions(false)) {
          Assert.assertTrue(subregion instanceof LocalRegion);
          if (subregion instanceof PartitionedRegion) {
            PartitionedRegion pr = (PartitionedRegion) subregion;
            if (pr.getColocatedWith() != null) {
              colocatedChildRegions.add(root);
              found = true;
              break;
            }
          }
        }
        if (!found) {
          generateRegion(root); // normal non pr regions
          generatedRegions.add(root);
        }
      }
    }
    TreeSet<Region<?, ?>> rColSet = new TreeSet<>(new RegionComparator());
    rColSet.addAll(colocatedChildRegions);
    for (Region<?, ?> root : rColSet) {
      Assert.assertTrue(root instanceof LocalRegion);
      if (root instanceof PartitionedRegion) {
        PartitionedRegion pr = (PartitionedRegion) root;
        PartitionedRegion colocatedWithPr = ColocationHelper.getColocatedRegion(pr);
        if (colocatedWithPr != null && !generatedRegions.contains(colocatedWithPr)) {
          generateRegion(colocatedWithPr);
          generatedRegions.add(colocatedWithPr);
        }
        if (!generatedRegions.contains(root)) {
          generateRegion(root);
          generatedRegions.add(root);
        }
      } else {
        generateRegion(root);
        generatedRegions.add(root);
      }
    }
  }
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