JAXBContext jaxbContext = JAXBContext.newInstance(Customer.class); SchemaOutputResolver sor = new MySchemaOutputResolver(); jaxbContext.generateSchema(sor);
context.generateSchema(new SchemaOutputResolver() {
context.generateSchema(new SchemaOutputResolver() {
context.generateSchema( new SchemaOutputResolver() {
public static void main(String[] args) throws Exception { JAXBContext jaxbContext = DeploymentDescriptorIO.getContext(); SchemaOutputResolver sor = new FileSchemaOutputResolver(); jaxbContext.generateSchema(sor); }
/** * @param outputResolver xml schema resolver * @throws IOException if I/O error occurred * @see javax.xml.bind.JAXBContext#generateSchema(javax.xml.bind.SchemaOutputResolver) */ public void generateSchema(SchemaOutputResolver outputResolver) throws IOException { wrappedContext.generateSchema(outputResolver); }
import java.io.IOException; import javax.xml.bind.*; import javax.xml.transform.Result; import javax.xml.transform.stream.StreamResult; public class GenerateSchema { public static void main(String[] args) throws Exception { JAXBContext jc = JAXBContext.newInstance(Root.class); jc.generateSchema(new SchemaOutputResolver() { @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException { StreamResult result = new StreamResult(System.out); result.setSystemId(suggestedFileName); return result; } }); } }
jc.generateSchema(new SchemaOutputResolver() { @Override public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
context.generateSchema(new SchemaOutputResolver() {
context.generateSchema(new SchemaOutputResolver() { int counter = 0;
public void generateSchema(SchemaOutputResolver outputResolver) throws IOException { JAXBContext jaxbContext = null; try { jaxbContext = schemaGenerator.call(); } catch (Exception e) { } if (jaxbContext == null) { throw new UnsupportedOperationException("Schema generation is not supported"); } jaxbContext.generateSchema(outputResolver); }
public void generateSchema(SchemaOutputResolver outputResolver) throws IOException { JAXBContext jaxbContext = null; try { jaxbContext = schemaGenerator.call(); } catch (Exception e) { } if (jaxbContext == null) { throw new UnsupportedOperationException("Schema generation is not supported"); } jaxbContext.generateSchema(outputResolver); }
Class[] classes = new Class[4]; classes[0] = org.example.customer_example.AddressType.class; classes[1] = org.example.customer_example.ContactInfo.class; classes[2] = org.example.customer_example.CustomerType.class; classes[3] = org.example.customer_example.PhoneNumber.class; JAXBContext jaxbContext = JAXBContext.newInstance(classes); SchemaOutputResolver sor = new MySchemaOutputResolver(); jaxbContext.generateSchema(sor);
public static Map<String, String> generateSchema(JAXBContext context) throws IOException { StringResolverImpl resolver = new StringResolverImpl(); context.generateSchema(resolver); Map<String, String> xsds = new HashMap<String, String>(); for (Map.Entry<String, StreamResult> xsd : resolver.getResults().entrySet()) { xsds.put(xsd.getKey(), xsd.getValue().getWriter().toString()); } return xsds; }
public static Map<String, String> generateSchema(JAXBContext context) throws IOException { StringResolverImpl resolver = new StringResolverImpl(); context.generateSchema(resolver); Map<String, String> xsds = new HashMap<String, String>(); for (Map.Entry<String, StreamResult> xsd : resolver.getResults().entrySet()) { xsds.put(xsd.getKey(), xsd.getValue().getWriter().toString()); } return xsds; }
public static String generateSchemma(Class<?>... classes) { try { JAXBContext jc = JAXBContext.newInstance(classes); StringSchemaOutputResolver ssor = new StringSchemaOutputResolver(); jc.generateSchema(ssor); return ssor.getSchemma(); } catch (Exception e) { throw new RuntimeException("Failed to generate schemma", e); } } }
static public File generateSchema(Class<?> clss) throws CRCLException { try { JAXBContext jaxbContext = JAXBContext.newInstance(clss); CRCLSchemaOutputResolver sor = new CRCLSchemaOutputResolver(); jaxbContext.generateSchema(sor); return sor.getFile(); } catch (JAXBException | IOException ex) { throw new CRCLException(ex); } }
public Map<String,String> toXsd(final Object domainObject, final IsisSchemas isisSchemas) { try { final Class<?> domainClass = domainObject.getClass(); final JAXBContext context = jaxbContextFor(domainClass); final CatalogingSchemaOutputResolver outputResolver = new CatalogingSchemaOutputResolver(isisSchemas); context.generateSchema(outputResolver); return outputResolver.asMap(); } catch (final IOException ex) { throw new ApplicationException(ex); } } }
private String schemaTest(Class<?>... classes) throws IOException, JAXBException { Assert.assertTrue(schema().isEmpty()); JAXBContext.newInstance(classes).generateSchema(sink); Assert.assertFalse(schema().isEmpty()); return schema(); }
@Test public void generateSchema() throws Exception { File schemaFile = fa.expecting("foreign-sources.xsd"); c.generateSchema(new TestOutputResolver(schemaFile)); if (fa.isInitialized()) { fa.deleteExpected(); } }