code: public void writeXsd(final OutputStream out) {
  
      SchemaOutputResolver sor = new SchemaOutputResolver() {
  
        @Override
        public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
  
          StreamResult streamResult = new StreamResult(out);
          streamResult.setSystemId(suggestedFileName);
          return streamResult;
        }
  
      };
      try {
        this.jaxbContext.generateSchema(sor);
      } catch (IOException e) {
        throw new IllegalStateException("Failed to generate and write the XSD schema!", e);
      }
    }
docs: Generates the XSD (XML Schema Definition) to the given {@link OutputStream}.
  
  @param out is the {@link OutputStream} to write to.