This tool is used to generate the given input XML to create a new XSD format file
try { //input file in the place of filename //prior to this get xmlbeans.jar File file=new File(filename); System.out.println(file.getFileName()); Reader reader[]=new Reader[1]; reader[0]=new InputStreamReader(file.getInputStream()); Inst2XsdOptions inst2XsdOptions=new Inst2XsdOptions(); inst2XsdOptions.setDesign(Inst2XsdOptions.DESIGN_SALAMI_SLICE); inst2XsdOptions.setUseEnumerations(Inst2XsdOptions.ENUMERATION_NEVER); SchemaDocument[] schemaDocument = Inst2Xsd.inst2xsd(reader, inst2XsdOptions); StringWriter writer = new StringWriter(); schemaDocument[0].save(writer, new XmlOptions().setSavePrettyPrint()); writer.close(); String xmlText = writer.toString(); System.out.println(xmlText); OutputStream stream= response.getOutputStream(); response.setContentType("application/zip"); String name=file.getFileName(); StringBuffer buffer=new StringBuffer(name); buffer.substring(0, name.length()-3); buffer.delete(name.length()-3, name.length()); response.setHeader( "Content-Disposition", "attachment; filename=\"" + buffer.append("xsd") + "\"" ); stream.write(xmlText.getBytes()); stream.flush(); stream.close(); } catch(IOException ie) { ie.printStackTrace(); } catch (Exception e) { e.printStackTrace(); }