docs: private String parseXMLDecl(String encoding) throws SAXException,
              IOException {
          String version;
          String encodingName = null;
          String standalone = null;
          int flags = LIT_DISABLE_CREF | LIT_DISABLE_PE | LIT_DISABLE_EREF;
  
          // Read the version.
          require("version");
          parseEq();
          checkLegalVersion(version = readLiteral(flags));
          if (!version.equals("1.0")) {
              if (version.equals("1.1")) {
                  fatal("XML 1.1 not supported."); // 2006-04-24 hsivonen
              } else {
                  fatal("illegal XML version", version, "1.0"); // removed 1.1
                  // -- 2006-04-24
                  // hsivonen
              }
          } else {
              xmlVersion = XML_10;
          }
          // Try reading an encoding declaration.
          boolean white = tryWhitespace();
  
          if (tryRead("encoding")) {
              if (!white) {
                  fatal("whitespace required before 'encoding='");
              }
              parseEq();
              encodingName = readLiteral(flags);
              checkEncodingLiteral(encodingName); // 2006-04-28 hsivonen
              if (reader == null) {
                  draconianInputStreamReader(encodingName, is, true);
              } else {
                  checkEncodingMatch(encoding, encodingName);
              }
          }
  
          // Try reading a standalone declaration
          if (encodingName != null) {
              white = tryWhitespace();
          } else {
              if (encoding == null) {
                  draconianInputStreamReader("UTF-8", is, false); // 2006-04-24
                  // hsivonen
              }
              warnAboutLackOfEncodingDecl(encoding);
          }
          if (tryRead("standalone")) {
              if (!white) {
                  fatal("whitespace required before 'standalone='");
              }
              parseEq();
              standalone = readLiteral(flags);
              if ("yes".equals(standalone)) {
                  docIsStandalone = true;
              } else if (!"no".equals(standalone)) {
                  fatal("standalone flag must be 'yes' or 'no'");
              }
          }
  
          skipWhitespace();
          require("?>");
  
          return encodingName;
      }