Create XSD from Java bean or from XML using JAXB -
i using 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 generating xml need xsd need create xsd 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 create xsd java beans or 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 solve issue.
Comments
Post a Comment