Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
User.java - Java Data Type Class Generated by XJC
How to read the Java code generated from XML Schema with XJC (XML to Java Compiler)?
✍: FYIcenter.com
To read the Java code generated from XML Schema with XJC (XML to Java Compiler), you can simply open it in any Java code development tool, or just a text edit.
For example, if you open the Java code, generated/User.java, generated from the previous tutorial, you will see the following after removing all comments in the code:
package generated; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSchemaType; import javax.xml.bind.annotation.XmlType; import javax.xml.datatype.XMLGregorianCalendar; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "", propOrder = { "birthDate", "name", "sex" }) @XmlRootElement(name = "User") public class User { @XmlElement(name = "BirthDate", required = true) @XmlSchemaType(name = "date") protected XMLGregorianCalendar birthDate; @XmlElement(name = "Name", required = true) protected String name; @XmlElement(name = "Sex", required = true) protected String sex; @XmlAttribute(name = "ID", required = true) protected int id; public XMLGregorianCalendar getBirthDate() { return birthDate; } public void setBirthDate(XMLGregorianCalendar value) { this.birthDate = value; } public String getName() { return name; } public void setName(String value) { this.name = value; } public String getSex() { return sex; } public void setSex(String value) { this.sex = value; } public int getID() { return id; } public void setID(int value) { this.id = value; } }
The generated Java code is very straightforward. The generated.User class is declared with protected properties for all child elements and attributes defined in for the "User" element in the user.xsd file.
⇒ XJC -p Option for Class Package Name
⇐ Generate Java Code from XML Schema with XJC
2018-05-08, 1422🔥, 0💬
Popular Posts:
The Digester package lets you configure an XML -> Java object mapping module, which triggers certain...
JDK 11 java.sql.rowset.jmod is the JMOD file for JDK 11 SQL Rowset module. JDK 11 SQL Rowset module ...
What is jxl.jar 2.6.12? jxl.jar 2.6.12 is the JAR file for Java Excel API 2.6.12, which is a Java li...
JLayer is a library that decodes/plays/converts MPEG 1/2/2.5 Layer 1/2/3 (i.e. MP3) in real time for...
JRE 8 rt.jar is the JAR file for JRE 8 RT (Runtime) libraries. JRE (Java Runtime) 8 is the runtime e...