SlideShare a Scribd company logo
1 of 22
Download to read offline
XML Parsing Using JAXB
● Object (DOM, JDOM….etc)
● PUSH (SAX)
● PULL(Stax)
● JAXB(Java Architecture for XML Binding)
● Defines an API for reading and writing Java objects to and from XML
documents.
● Don't need to be aware of XML parsing techniques
● No extra dependency needed (its inside JDK)
● Used as a standard in many cases
XML JAXB
Java
Objects
●
●
JAXB uses annotations to indicate the central elements.
Annotation Definition
@XmlRootElement(namespace = "namespace") Define the root element for an XML tree
@XmlType(propOrder = { "field2", "field1",.. }) Allows to define the order in which the fields are written in
the XML file
@XmlElement Define the XML element which will be used.
@XmlAttribute Define the attribute of an element
Marshalling UnMarshalling
XML :
<?xml version="1.0" encoding="UTF-8"?>
<booking xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
<company name="ACME Consulting">
<address>10 Coyote Avenue, Arizona, USA</address>
<contact name="Duke" email="duke@acme.com"
telephone="1234567890"/>
</company>
<student firstName="Jane" surname="Dow"/>
<student firstName="John" surname="Doe"/>
</booking>
XSD :
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="booking" type="courseBooking"/>
<xsd:complexType name="courseBooking">
<xsd:sequence>
<xsd:element ref="company" />
<xsd:element ref="student" minOccurs="1" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="courseReference" type="xsd:string" use="required"/>
<xsd:attribute name="courseDate" type="xsd:date" use="required"/>
<xsd:attribute name="invoiceReference" type="xsd:string" use="required"/>
<xsd:attribute name="totalPrice" type="xsd:decimal" use="required"/>
</xsd:complexType>
<xsd:element name="student" type="studentType"/>
<xsd:complexType name="studentType">
<xsd:attribute name="firstName" type="xsd:string" use="required"/>
<xsd:attribute name="surname" type="xsd:string" use="required"/>
</xsd:complexType>
<xsd:element name="company" type="companyType"/>
<xsd:complexType name="companyType">
<xsd:sequence>
<xsd:element name="address"/>
<xsd:element ref="contact" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string"/>
</xsd:complexType>
<xsd:element name="contact" type="contactType"/>
<xsd:complexType name="contactType">
<xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="telephone" type="xsd:string" use="required"/>
<xsd:attribute name="email" type="xsd:string" use="required"/>
</xsd:complexType>
</xsd:schema>
run the following command:
$xjc course-booking.xsd -p org.wso2.jaxb.training -d src/generated
● -d <dir>: Place the generated files into this directory.
● -p <package>: Place the generated files in this package.
● -nv: Don't perform strict validation of the input schema.
● -httpproxy <proxy>: Use this if you are behind a proxy. Takes the format [user[:password]@]proxyHost[:proxyPort].
● -classpath <arg>: Specify the classpath, if necessary.
● -readOnly: Generates read-only source code files, if your OS supports this.
There is also an equivalent ant task, which makes it quite easy to integrate into an Ant or Maven-based build process.
@XmlAttribute
For complete reference please visit : https://jaxb.java.net/tutorial/section_6_2_1-A-Survey-Of-
JAXB-Annotations.html#A%20Survey%20Of%20JAXB%20Annotations
JAXB advantages
o It is very simple to use than DOM or SAX
parser
o We can marshal XML file to other data
targets like inputStream,URL,DOM node.
o We can unmarshal XML file from other
data targets.
o We don't need to be aware of XML parsing
techniques.
o We don't need to access XML in tree
structure always.
JAXB disadvantages
o JAXB is high layer API so it has less
control on parsing than SAX or DOM.
o It has some overhead tasks so it is slower
than SAX.
Questions?
❖ https://jaxb.java.net/tutorial/
❖ http://www.mkyong.com/java/jaxb-hello-world-example/
❖ http://javapostsforlearning.blogspot.com/2013/02/jaxb-tutorial.html
Contact us !

More Related Content

What's hot

Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
Hicham QAISSI
 

What's hot (20)

Ogh Ace Case, Part 1 and 2, Oracle Xml Database, Marco Gralike
Ogh Ace Case, Part 1 and 2, Oracle Xml Database, Marco GralikeOgh Ace Case, Part 1 and 2, Oracle Xml Database, Marco Gralike
Ogh Ace Case, Part 1 and 2, Oracle Xml Database, Marco Gralike
 
Database Programming Techniques
Database Programming TechniquesDatabase Programming Techniques
Database Programming Techniques
 
Xml parsers
Xml parsersXml parsers
Xml parsers
 
Java XML Parsing
Java XML ParsingJava XML Parsing
Java XML Parsing
 
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
Real World Experience With Oracle Xml Database 11g An Oracle Ace’s Perspectiv...
 
JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Database Access With JDBC
Database Access With JDBCDatabase Access With JDBC
Database Access With JDBC
 
Java full stack1
Java full stack1Java full stack1
Java full stack1
 
Jstl Guide
Jstl GuideJstl Guide
Jstl Guide
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
Advance java session 5
Advance java session 5Advance java session 5
Advance java session 5
 
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
XMLDB Building Blocks And Best Practices - Oracle Open World 2008 - Marco Gra...
 
PostgreSQL - Case Study
PostgreSQL - Case StudyPostgreSQL - Case Study
PostgreSQL - Case Study
 
SQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJSQL, Embedded SQL, Dynamic SQL and SQLJ
SQL, Embedded SQL, Dynamic SQL and SQLJ
 
java jdbc connection
java jdbc connectionjava jdbc connection
java jdbc connection
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)JDBC Basics (In 20 Minutes Flat)
JDBC Basics (In 20 Minutes Flat)
 
Jdom how it works & how it opened the java process
Jdom how it works & how it opened the java processJdom how it works & how it opened the java process
Jdom how it works & how it opened the java process
 
Jdbc presentation
Jdbc presentationJdbc presentation
Jdbc presentation
 
Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)Java Database Connectivity (JDBC)
Java Database Connectivity (JDBC)
 

Viewers also liked

RESTful services with JAXB and JPA
RESTful services with JAXB and JPARESTful services with JAXB and JPA
RESTful services with JAXB and JPA
Shaun Smith
 
Ado.net xml data serialization
Ado.net xml data serializationAdo.net xml data serialization
Ado.net xml data serialization
Raghu nath
 
Xml serialization
Xml serializationXml serialization
Xml serialization
Raghu nath
 
Metricas de calidad de software
Metricas de calidad de softwareMetricas de calidad de software
Metricas de calidad de software
isisparada
 

Viewers also liked (16)

RESTful services with JAXB and JPA
RESTful services with JAXB and JPARESTful services with JAXB and JPA
RESTful services with JAXB and JPA
 
Ado.net xml data serialization
Ado.net xml data serializationAdo.net xml data serialization
Ado.net xml data serialization
 
SAX, DOM & JDOM parsers for beginners
SAX, DOM & JDOM parsers for beginnersSAX, DOM & JDOM parsers for beginners
SAX, DOM & JDOM parsers for beginners
 
Xml serialization
Xml serializationXml serialization
Xml serialization
 
Xml & Java
Xml & JavaXml & Java
Xml & Java
 
Ado.Net Tutorial
Ado.Net TutorialAdo.Net Tutorial
Ado.Net Tutorial
 
Xml parsing
Xml parsingXml parsing
Xml parsing
 
Serialization in .NET
Serialization in .NETSerialization in .NET
Serialization in .NET
 
Intro To .Net Threads
Intro To .Net ThreadsIntro To .Net Threads
Intro To .Net Threads
 
Xml And JSON Java
Xml And JSON JavaXml And JSON Java
Xml And JSON Java
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 
Delegates and events
Delegates and events   Delegates and events
Delegates and events
 
What are actionable insights? (Introduction to Operational Analytics Software)
What are actionable insights? (Introduction to Operational Analytics Software)What are actionable insights? (Introduction to Operational Analytics Software)
What are actionable insights? (Introduction to Operational Analytics Software)
 
Metricas Ingenieria De Software
Metricas Ingenieria De SoftwareMetricas Ingenieria De Software
Metricas Ingenieria De Software
 
JAX B
JAX BJAX B
JAX B
 
Metricas de calidad de software
Metricas de calidad de softwareMetricas de calidad de software
Metricas de calidad de software
 

Similar to XML parsing using jaxb

Content Storage With Apache Jackrabbit
Content Storage With Apache JackrabbitContent Storage With Apache Jackrabbit
Content Storage With Apache Jackrabbit
Jukka Zitting
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
Marco Gralike
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Marco Gralike
 

Similar to XML parsing using jaxb (20)

Ch23
Ch23Ch23
Ch23
 
Ch23 xml processing_with_java
Ch23 xml processing_with_javaCh23 xml processing_with_java
Ch23 xml processing_with_java
 
XML
XMLXML
XML
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 
Extensible markup language attacks
Extensible markup language attacksExtensible markup language attacks
Extensible markup language attacks
 
Content Storage With Apache Jackrabbit
Content Storage With Apache JackrabbitContent Storage With Apache Jackrabbit
Content Storage With Apache Jackrabbit
 
Ajax xml json
Ajax xml jsonAjax xml json
Ajax xml json
 
Java Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & ServletsJava Course 12: XML & XSL, Web & Servlets
Java Course 12: XML & XSL, Web & Servlets
 
5 xml parsing
5   xml parsing5   xml parsing
5 xml parsing
 
Core Java Programming Language (JSE) : Chapter X - I/O Fundamentals
Core Java Programming Language (JSE) : Chapter X - I/O Fundamentals Core Java Programming Language (JSE) : Chapter X - I/O Fundamentals
Core Java Programming Language (JSE) : Chapter X - I/O Fundamentals
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
OPP2010 (Brussels) - Programming with XML in PL/SQL - Part 1
 
Processing XML
Processing XMLProcessing XML
Processing XML
 
Slickdemo
SlickdemoSlickdemo
Slickdemo
 
Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.Using Stratego/XT for generation of software connectors.
Using Stratego/XT for generation of software connectors.
 
Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.Null Bachaav - May 07 Attack Monitoring workshop.
Null Bachaav - May 07 Attack Monitoring workshop.
 
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco GralikeBoost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
Boost Your Environment With XMLDB - UKOUG 2008 - Marco Gralike
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Red Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop LabsRed Hat Agile integration Workshop Labs
Red Hat Agile integration Workshop Labs
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
VictoriaMetrics
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 

Recently uploaded (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 

XML parsing using jaxb

  • 2.
  • 3. ● Object (DOM, JDOM….etc) ● PUSH (SAX) ● PULL(Stax) ● JAXB(Java Architecture for XML Binding)
  • 4. ● Defines an API for reading and writing Java objects to and from XML documents. ● Don't need to be aware of XML parsing techniques ● No extra dependency needed (its inside JDK) ● Used as a standard in many cases XML JAXB Java Objects
  • 6.
  • 7.
  • 8. JAXB uses annotations to indicate the central elements. Annotation Definition @XmlRootElement(namespace = "namespace") Define the root element for an XML tree @XmlType(propOrder = { "field2", "field1",.. }) Allows to define the order in which the fields are written in the XML file @XmlElement Define the XML element which will be used. @XmlAttribute Define the attribute of an element
  • 10. XML : <?xml version="1.0" encoding="UTF-8"?> <booking xmlns:xsi="http://www.w3.org/2001/XMLSchema- instance"> <company name="ACME Consulting"> <address>10 Coyote Avenue, Arizona, USA</address> <contact name="Duke" email="duke@acme.com" telephone="1234567890"/> </company> <student firstName="Jane" surname="Dow"/> <student firstName="John" surname="Doe"/> </booking> XSD : <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="booking" type="courseBooking"/> <xsd:complexType name="courseBooking"> <xsd:sequence> <xsd:element ref="company" /> <xsd:element ref="student" minOccurs="1" maxOccurs="unbounded"/> </xsd:sequence> <xsd:attribute name="courseReference" type="xsd:string" use="required"/> <xsd:attribute name="courseDate" type="xsd:date" use="required"/> <xsd:attribute name="invoiceReference" type="xsd:string" use="required"/> <xsd:attribute name="totalPrice" type="xsd:decimal" use="required"/> </xsd:complexType> <xsd:element name="student" type="studentType"/> <xsd:complexType name="studentType"> <xsd:attribute name="firstName" type="xsd:string" use="required"/> <xsd:attribute name="surname" type="xsd:string" use="required"/> </xsd:complexType> <xsd:element name="company" type="companyType"/> <xsd:complexType name="companyType"> <xsd:sequence> <xsd:element name="address"/> <xsd:element ref="contact" /> </xsd:sequence> <xsd:attribute name="name" type="xsd:string"/> </xsd:complexType> <xsd:element name="contact" type="contactType"/> <xsd:complexType name="contactType"> <xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="telephone" type="xsd:string" use="required"/> <xsd:attribute name="email" type="xsd:string" use="required"/> </xsd:complexType> </xsd:schema>
  • 11. run the following command: $xjc course-booking.xsd -p org.wso2.jaxb.training -d src/generated ● -d <dir>: Place the generated files into this directory. ● -p <package>: Place the generated files in this package. ● -nv: Don't perform strict validation of the input schema. ● -httpproxy <proxy>: Use this if you are behind a proxy. Takes the format [user[:password]@]proxyHost[:proxyPort]. ● -classpath <arg>: Specify the classpath, if necessary. ● -readOnly: Generates read-only source code files, if your OS supports this. There is also an equivalent ant task, which makes it quite easy to integrate into an Ant or Maven-based build process.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18. @XmlAttribute For complete reference please visit : https://jaxb.java.net/tutorial/section_6_2_1-A-Survey-Of- JAXB-Annotations.html#A%20Survey%20Of%20JAXB%20Annotations
  • 19. JAXB advantages o It is very simple to use than DOM or SAX parser o We can marshal XML file to other data targets like inputStream,URL,DOM node. o We can unmarshal XML file from other data targets. o We don't need to be aware of XML parsing techniques. o We don't need to access XML in tree structure always. JAXB disadvantages o JAXB is high layer API so it has less control on parsing than SAX or DOM. o It has some overhead tasks so it is slower than SAX.
  • 21. ❖ https://jaxb.java.net/tutorial/ ❖ http://www.mkyong.com/java/jaxb-hello-world-example/ ❖ http://javapostsforlearning.blogspot.com/2013/02/jaxb-tutorial.html