private static int buildElementMapXPath(final LinkedHashMap<String, CacheElement> elementMap,
      final Document schema, final Node parent, int rank, final String xPath,
      final XPathContext xPathContext) throws XPathExpressionException {
    final NodeList children = XmlUtils.query(parent, xPath, xPathContext);
    for (int i = 0; i < children.getLength(); i++) {
      final Element child = (Element) children.item(i);
      switch (child.getNodeName()) {
        case XSD_ALL_CHILDREN:
          final String name = getAttribute(child, "name");
          elementMap.put(name, new CacheElement(name, rank++, isMultiple(child)));
          break;
        case "xsd:choice":
        case "xsd:sequence":
          rank = buildElementMapXPath(elementMap, schema, child, rank,
              XSD_CHOICE_OR_SEQUENCE_CHILDREN, xPathContext);
          break;
        case "xsd:any":
          // ignore extensions
          break;
        default:
          throw new UnsupportedOperationException(
              "Unsupported child type '" + child.getNodeName() + "'");
      }
    }

    return rank;
  }
Build element map for elements matching <code>xPath</code> relative to <code>parent</code> into
<code>elementMap</code> .

@param elementMap to add elements to
@param schema {@link Document} for schema.
@param parent {@link Element} to query XPath.
@param rank current rank of elements.
@param xPath XPath to query for elements.
@param xPathContext XPath context for queries.
@return final rank of elements.
@since GemFire 8.1
geode-core/src/main/java/org/apache/geode/management/internal/configuration/domain/CacheElement.java