XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="customer" type="customer-type"/>
<xsd:complexType name="customer-type">
<xsd:sequence>
<xsd:element name="picture" type="xsd:hexBinary"/>
<xsd:element name="resume" type="xsd:base64Binary"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Code Sample
XMLField pictureField = new XMLField("picture/text()")
pictureField.setSchemaType(XMLConstants.HEX_BINARY_QNAME);
Setting custom conversion pairs: By default in TopLink XML built-in schema types are associated with java classes and vice versa. These default pairs can be modified by the user using the addJavaConversion and addXMLConversion api. For example by default a java.util.Calendar is mapped to the dateTime schema type so the XML will be formated based on that type. Below are the default schema type to java type conversion pairs and the default java type to schema type conversion pairs.
XML schema type to Java type default conversion pairs
Schema Type | Java Type |
---|---|
base64Binary | byte[] |
boolean | boolean |
byte | byte |
date | java.util.Calendar |
dateTime | java.util.Calendar |
decimal | java.math.BigDecimal |
double | double |
float | float |
hexBinary | byte[] |
int | int |
integer | java.math.BigInteger |
long | long |
QName | javax.xml.namespace.QName |
time | java.util.Calendar |
unsignedByte | short |
unsignedInt | long |
unsignedShort | int |
anySimpleType | java.lang.String |
Java type to XML schema type default conversion pairs
Java Type | Schema Type |
---|---|
byte[] | hexBinary |
java.lang.Byte[] | hexBinary |
java.math.BigDecimal | decimal |
java.math.BigInteger | integer |
boolean | boolean |
java.lang.Boolean | boolean |
java.lang.Byte | Byte |
byte | byte |
java.util.Calendar | dateTime |
java.util.GregorianCalendar | dateTime |
double | double |
java.lang.Double | double |
float | float |
java.lang.Float | float |
int | int |
java.lang.Integer | int |
long | long |
java.lang.Long | long |
short | short |
java.lang.Short | short |
javax.xml.namespace.QName | QName |
java.lang.String | string |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|