docs: protected void createContainerXML(final BuildData buildData, final Level container, final Document doc, final Element parentNode,
              final String parentFileLocation, final Boolean flattenStructure) throws BuildProcessingException {
          final List<org.jboss.pressgang.ccms.contentspec.Node> levelData = container.getChildNodes();
  
          // Get the name of the element based on the type
          final String elementName = container.getLevelType() == LevelType.PROCESS ? "chapter" : container.getLevelType().getTitle()
                  .toLowerCase(Locale.ENGLISH);
          final Element intro = doc.createElement(elementName + "intro");
  
          // Storage container to hold the levels so they can be added in proper order with the intro
          final LinkedList<Node> childNodes = new LinkedList<Node>();
  
          // Add the section and topics for this level to the chapter.xml
          for (final org.jboss.pressgang.ccms.contentspec.Node node : levelData) {
              // Check if the app should be shutdown
              if (isShuttingDown.get()) {
                  return;
              }
  
              if (node instanceof Level && node.getParent() != null && (((Level) node).getParent().getLevelType() == LevelType.BASE || (
                      (Level) node).getParent().getLevelType() == LevelType.PART) && ((Level) node).getLevelType() != LevelType
                      .INITIAL_CONTENT) {
                  final Level childContainer = (Level) node;
  
                  // Create a new file for the Chapter/Appendix
                  final Element xiInclude = createSubRootContainerXML(buildData, doc, childContainer, parentFileLocation, flattenStructure);
                  if (xiInclude != null) {
                      childNodes.add(xiInclude);
                  }
              } else if (node instanceof Level && ((Level) node).getLevelType() == LevelType.INITIAL_CONTENT) {
                  if (container.getLevelType() == LevelType.PART) {
                      addLevelsInitialContent(buildData, (InitialContent) node, doc, intro, false);
                  } else {
                      addLevelsInitialContent(buildData, (InitialContent) node, doc, parentNode, false);
                  }
              } else if (node instanceof Level) {
                  final Level childLevel = (Level) node;
  
                  // Create the section and its title
                  final Element sectionNode = doc.createElement("section");
                  setUpRootElement(buildData, childLevel, doc, sectionNode);
  
                  // Ignore sections that have no spec topics
                  if (!childLevel.hasSpecTopics() && !childLevel.hasCommonContents()) {
                      if (buildData.getBuildOptions().isAllowEmptySections()) {
                          Element warning = doc.createElement("warning");
                          warning.setTextContent("No Content");
                          sectionNode.appendChild(warning);
                      } else {
                          continue;
                      }
                  } else {
                      // Add this sections child sections/topics
                      createContainerXML(buildData, childLevel, doc, sectionNode, parentFileLocation, flattenStructure);
                  }
  
                  childNodes.add(sectionNode);
              } else if (node instanceof CommonContent) {
                  final CommonContent commonContent = (CommonContent) node;
                  final Node xiInclude = XMLUtilities.createXIInclude(doc, "Common_Content/" + commonContent.getFixedTitle());
                  if (commonContent.getParent() != null && commonContent.getParent().getLevelType() == LevelType.PART) {
                      intro.appendChild(xiInclude);
                  } else {
                      childNodes.add(xiInclude);
                  }
              } else if (node instanceof SpecTopic) {
                  final SpecTopic specTopic = (SpecTopic) node;
                  final Node topicNode = createTopicDOMNode(specTopic, doc, flattenStructure, parentFileLocation);
  
                  // Add the node to the chapter
                  if (topicNode != null) {
                      if (specTopic.getParent() != null && ((Level) specTopic.getParent()).getLevelType() == LevelType.PART) {
                          intro.appendChild(topicNode);
                      } else {
                          childNodes.add(topicNode);
                      }
                  }
              }
          }
  
          // Add the child nodes and intro to the parent
          if (intro.hasChildNodes()) {
              parentNode.appendChild(intro);
          }
  
          for (final Node node : childNodes) {
              parentNode.appendChild(node);
          }
      }