code: private Set<String> getNamespacePrefixes(ZipFile zipFile, ZipArchiveEntry entry) throws IOException {
      try (InputStream entryStream = zipFile.getInputStream(entry)) {
        SAXParser parser = SAX_PARSER_FACTORY.newSAXParser();
        final Set<String> prefixes = new LinkedHashSet<>();
  
        final AtomicBoolean foundRootElement = new AtomicBoolean(false);
        DefaultHandler handler = new DefaultHandler() {
          @Override
          public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
            // validate that XML file contains FileVault XML content
            if (StringUtils.equals(uri, JCR_NAMESPACE.getURI()) && StringUtils.equals(localName, "root")) {
              foundRootElement.set(true);
            }
          }
          @Override
          public void startPrefixMapping(String prefix, String uri) throws SAXException {
            if (StringUtils.isNotBlank(prefix)) {
              prefixes.add(prefix);
            }
          }
        };
        parser.parse(entryStream, handler);
  
        if (!foundRootElement.get()) {
          return null;
        }
        else {
          return prefixes;
        }
      }
      catch (IOException | SAXException | ParserConfigurationException ex) {
        throw new IOException("Error parsing " + entry.getName(), ex);
      }
    }
docs: Parses XML file with namespace-aware SAX parser to get defined namespaces prefixes in order of appearance
  (to keep the same order when outputting the XML file again).
  @param zipFile ZIP file
  @param entry ZIP entry
  @return Ordered set with namespace prefixes in correct order.
  Returns null if given XML file does not contain FileVault XML content.
  @throws IOException