/** * @param args output file path */ public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: <filepath>"); System.exit(0); } final File f = new File(args[0]); final Writer w = new FileWriter(f); w.write(XMLSchemaGenerator.xmlSchemaAsString(StandaloneCatalog.class)); w.close(); } }
public static Unmarshaller unmarshaller(final Class<?> clazz) throws JAXBException, SAXException, IOException, TransformerException { final JAXBContext context = JAXBContext.newInstance(clazz); final SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); final Unmarshaller um = context.createUnmarshaller(); final Schema schema = factory.newSchema(new StreamSource(XMLSchemaGenerator.xmlSchema(clazz))); um.setSchema(schema); return um; }
public static void main(final String[] args) throws IOException, TransformerException, JAXBException, ClassNotFoundException { if (args.length != 2) { printUsage(); System.exit(0); } final Class<?> clazz = ClassLoader.getSystemClassLoader().loadClass(args[1]); final JAXBContext context = JAXBContext.newInstance(clazz); String xsdFileName = "Schema.xsd"; if (args.length != 0) { xsdFileName = args[0] + "/" + xsdFileName; } final FileOutputStream s = new FileOutputStream(xsdFileName); pojoToXSD(context, s); }
public static InputStream xmlSchema(final Class<?> clazz) throws IOException, TransformerException, JAXBException { final ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_SCHEMA_SIZE_IN_BYTES); final JAXBContext context = JAXBContext.newInstance(clazz); pojoToXSD(context, output); return new ByteArrayInputStream(output.toByteArray()); }
public static String xmlSchemaAsString(final Class<?> clazz) throws IOException, TransformerException, JAXBException { final ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_SCHEMA_SIZE_IN_BYTES); final JAXBContext context = JAXBContext.newInstance(clazz); pojoToXSD(context, output); return new String(output.toByteArray()); }
/** * @param args output file path */ public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: <filepath>"); System.exit(0); } final File f = new File(args[0]); final Writer w = new FileWriter(f); w.write(XMLSchemaGenerator.xmlSchemaAsString(OverdueConfig.class)); w.close(); } }
@Test(groups = "fast", enabled = false) public void test() throws IOException, TransformerException, JAXBException { final InputStream stream = XMLSchemaGenerator.xmlSchema(XmlTestClass.class); System.out.println(IOUtils.toString(stream)); } }
public static void main(final String[] args) throws Exception { if (args.length != 1) { System.err.println("Usage: <filepath>"); System.exit(0); } final File f = new File(args[0]); final Writer w = new FileWriter(f); w.write(XMLSchemaGenerator.xmlSchemaAsString(StandaloneCatalog.class)); w.close(); } }