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, 1369🔥, 0💬
Popular Posts:
How to download and install xml-commons External Source Package? The source package contains Java so...
Saxon-HE (home edition) is an open source product available under the Mozilla Public License. It pro...
JDK 17 jdk.localedata.jmod is the JMOD file for JDK 17 Localedata module. JDK 17 Locale Data module ...
What Is commons-lang3-3.1.jar? commons-lang3-3.1.jar is the JAR file for Apache Commons Lang 3.1, wh...
JDK 17 jdk.compiler.jmod is the JMOD file for JDK 17 Compiler tool, which can be invoked by the "jav...