Created
August 18, 2014 15:34
-
-
Save gowrishankarin/81a5ba85762e3801b2c1 to your computer and use it in GitHub Desktop.
JAXB Schema Generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tribe21.domain; | |
import java.io.IOException; | |
import javax.xml.bind.JAXBContext; | |
import javax.xml.bind.JAXBException; | |
import javax.xml.bind.SchemaOutputResolver; | |
public class Application { | |
public static void main(String[] args) throws InterruptedException { | |
try { | |
JAXBContext jaxbContext = JAXBContext.newInstance(User.class); | |
SchemaOutputResolver sor = new MySchemaOutputResolver(); | |
jaxbContext.generateSchema(sor); | |
} catch (JAXBException e) { | |
// TODO Auto-generated catch block | |
e.printStackTrace(); | |
} catch (IOException ioe) { | |
ioe.printStackTrace(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tribe21.domain; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.xml.bind.SchemaOutputResolver; | |
import javax.xml.transform.stream.StreamResult; | |
public class MySchemaOutputResolver extends SchemaOutputResolver { | |
@Override | |
public javax.xml.transform.Result createOutput(String namespaceUri, | |
String suggestedFileName) throws IOException { | |
// TODO Auto-generated method stub | |
File file = new File(suggestedFileName); | |
StreamResult result = new StreamResult(file); | |
String wtf = file.toURI().toURL().toString(); | |
result.setSystemId(wtf); | |
return result; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 | |
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> | |
// Any modifications to this file will be lost upon recompilation of the source schema. | |
// Generated on: 2014.08.18 at 07:43:49 PM IST | |
// | |
package com.tribe21.domain; | |
import java.util.ArrayList; | |
public class User { | |
private String name; | |
private String address; | |
private String pin; | |
private String phone; | |
private ArrayList<String> emailIds; | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public ArrayList<String> getEmailIds() { | |
return emailIds; | |
} | |
public void setEmailIds(ArrayList<String> emailIds) { | |
this.emailIds = emailIds; | |
} | |
public String getAddress() { | |
return address; | |
} | |
public void setAddress(String address) { | |
this.address = address; | |
} | |
public String getPin() { | |
return pin; | |
} | |
public void setPin(String pin) { | |
this.pin = pin; | |
} | |
public String getPhone() { | |
return phone; | |
} | |
public void setPhone(String phone) { | |
this.phone = phone; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema"> | |
<xs:complexType name="user"> | |
<xs:sequence> | |
<xs:element name="address" type="xs:string" minOccurs="0"/> | |
<xs:element name="emailIds" type="xs:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/> | |
<xs:element name="name" type="xs:string" minOccurs="0"/> | |
<xs:element name="phone" type="xs:string" minOccurs="0"/> | |
<xs:element name="pin" type="xs:string" minOccurs="0"/> | |
</xs:sequence> | |
</xs:complexType> | |
</xs:schema> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment