private void digestConfigRecursively(Reader stream, String baseURI)
      throws IOException, SAXException, URISyntaxException, SmooksConfigurationException {
    Document configDoc;
    String streamData = StreamUtils.readStream(stream);

    try {
      configDoc =
          XmlUtil.parseStream(
              new StringReader(streamData),
              getDTDEntityResolver(),
              XmlUtil.VALIDATION_TYPE.DTD,
              true);
      logger.debug(
          "Using a deprecated Smooks configuration DTD '"
              + DTD_V10
              + "'.  Update configuration to use XSD '"
              + XSD_V10
              + "'.");
      digestV10DTDValidatedConfig(configDoc);
      logger.debug(
          "Using a deprecated Smooks configuration DTD '"
              + DTD_V10
              + "'.  Update configuration to use XSD '"
              + XSD_V10
              + "'.");
    } catch (Exception e) {
      // Must be an XSD based config...
      try {
        configDoc = XmlUtil.parseStream(new StringReader(streamData));
      } catch (ParserConfigurationException ee) {
        throw new SAXException("Unable to parse Smooks configuration.", ee);
      }

      XsdDOMValidator validator = new XsdDOMValidator(configDoc);
      String defaultNS = validator.getDefaultNamespace().toString();

      validator.validate();

      configStack.peek().defaultNS = defaultNS;
      if (XSD_V10.equals(defaultNS)) {
        if (validator.getNamespaces().size() > 1) {
          throw new SmooksConfigurationException(
              "Unsupported use of multiple configuration namespaces from inside a v1.0 Smooks configuration. Configuration extension not supported from a v1.0 configuration.  Use the v1.1 configuration namespace.");
        }
        digestV10XSDValidatedConfig(baseURI, configDoc);
      } else if (XSD_V11.equals(defaultNS)) {
        digestV11XSDValidatedConfig(baseURI, configDoc);
      } else {
        throw new SAXException(
            "Cannot parse Smooks configuration.  Unsupported default Namespace '"
                + defaultNS
                + "'.");
      }
    }

    if (resourcelist.isEmpty()) {
      throw new SAXException(
          "Invalid Content Delivery Resource archive definition file: 0 Content Delivery Resource definitions.");
    }
  }
  private void assertExtendedConfigOK(String configNamespace, String resourcePath) {
    InputStream resourceStream = ClassUtil.getResourceAsStream(resourcePath, classLoader);

    if (resourceStream == null) {
      throw new SmooksConfigurationException(
          "Unable to locate Smooks digest configuration '"
              + resourcePath
              + "' for extended resource configuration namespace '"
              + configNamespace
              + "'.  This resource must be available on the classpath.");
    }

    Document configDoc;
    try {
      configDoc = XmlUtil.parseStream(resourceStream);
    } catch (Exception e) {
      throw new SmooksConfigurationException(
          "Unable to parse namespace URI '" + configNamespace + "'.", e);
    }

    XsdDOMValidator validator;
    try {
      validator = new XsdDOMValidator(configDoc);
    } catch (SAXException e) {
      throw new SmooksConfigurationException(
          "Unable to create XsdDOMValidator instance for extended resource config '"
              + resourcePath
              + "'.",
          e);
    }

    String defaultNS = validator.getDefaultNamespace().toString();
    if (!XSD_V10.equals(defaultNS) && !XSD_V11.equals(defaultNS)) {
      throw new SmooksConfigurationException(
          "Extended resource configuration '"
              + resourcePath
              + "' default namespace must be a valid Smooks configuration namespace.");
    }
    if (validator.getNamespaces().size() > 1) {
      throw new SmooksConfigurationException(
          "Extended resource configuration '"
              + resourcePath
              + "' defines configurations from multiple namespaces.  This is not permitted.  Only use configurations from the base Smooks config namespaces e.g. '"
              + XSD_V11
              + "'.");
    }
  }