Upload
hosein-zare
View
136
Download
2
Tags:
Embed Size (px)
Citation preview
Java Architecture for XML Binding (JAXB)
What is JAXB?
MarshallingUnMarshallingAdaptersXSD Annotations
Marshalling
Marshalling
Marshalling
MarshallingConsole output
UnMarshalling
UnMarshallingConsole output
Adapters
Console output
XSD
XSDdata type
XSD
Annotations
@ XmlAccessorOrder @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
@ XmlAccessorType @XmlAccessorType(XmlAccessType.FIELD)
@ XmlAnyAttribute @XmlAnyAttribute public Map<QName, String> getConvertedAttributes()
{ ... }
@ XmlAnyElement@XmlAnyElement(lax = true)
Annotations
@ XmlAttribute @ XmlElement @ XmlElementRef @ XmlElementRefs
@XmlElementWrapper(name = "contacts") @XmlElementRefs({ @XmlElementRef(name = "phone", type = Phone.class, required = true), @XmlElementRef(name = "address", type = Address.class, required = true) }) private final List<ContactInfomation> contacts = new ArrayList<>();
@ XmlElements @ XmlElementWrapper
Annotations
@ XmlEnum
@XmlEnum(Integer.class) public enum Code { @XmlEnumValue("1") ONE, @XmlEnumValue("2") TWO; }_________________________________________
<xs:simpleType name="Code"> <xs:restriction base="xs:int"> <xs:enumeration value="1"/> <xs:enumeration value="2"/> </xs:restriction></xs:simpleType>
@ XmlEnumValue
@ XmlID @XmlID private String id;
_______________________________________<course id="1" name="Fundamentals of Programming"/>
@ XmlList @XmlList
private List<String> emailAddresses;_______________________________________
<emailAddresses>[email protected] [email protected]</emailAddresses>
@ XmlMimeType @XmlMimeType("image/jpeg")
Annotations
@ XmlMixed @ XmlSchema @XmlSchema(namespace = "http://www.example.org/customer") package org.example.customer;
______________________________________<customer xmlns="http://www.example.org/customer">
@ XmlSchemaType @XmlElement(name = "date-of-birth") @XmlSchemaType(name = "date") protected XMLGregorianCalendar dateOfBirth;
______________________________________
<xsd:element name="date-of-birth" type="xsd:date"/>
@ XmlTransient @
XmlRootElement @ XmlType@XmlRootElement@XmlType(propOrder = { "phoneNumbers", "name"})public class Customer extends Person {
private String password; private List<String> phoneNumbers;
@XmlTransient public String getPassword() { return password; }
public void setPassword(String password) {…
<customer><id>123</id><phone-number>555-1111</phone-
number> <phone-number>555-2222</phone-number> <name>Jane Doe</name></customer>