I am using this code
JAXBContext jc = JAXBContext.newInstance(Bookdata.class);
Bookdata bookdata=new Bookdata();
Marshaller marshaller = jc.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(bookdata, (OutputStream) output);
But it is generating XML But i need XSD I Need to create XSD like this:
<ArrayOfCommandInfoDTO>
<CommandInfoDTO>
<a:allowAddingGameCenterFriends>true</a:allowAddingGameCenterFriends>
<a:enter code here>allowAppInstallation>true</a:allowAppInstallation>
<a:allowAssistant>true</a:allowAssistant>
<a:allowAssistantWhileLocked>true</a:allowAssistantWhileLocked>
<a:allowCamera>true</a:allowCamera>
</CommandInfoDTO>
</ArrayOfCommandInfoDTO>
So Please tell me how to create XSD from java Beans or from XML
public class ObjToSchema {
public static void main(String[] args) throws IOException, JAXBException {
// TODO Auto-generated method stub
(JAXBContext.newInstance(Bookdata.class)).generateSchema(new DataSchemaOutputResolver());
}
}
public class DataSchemaOutputResolver extends SchemaOutputResolver {
@Override
public Result createOutput(String arg0, String arg1) throws IOException {
// TODO Auto-generated method stub
return new StreamResult(new File("d:/data.xsd"));
}
}
Hope this will solve your issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With