Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Chapter 11. Using Simple Types
Abstract
XML Schema simple types are either XML Schema primitive types like xsd:int, or are defined using the
simpleType element. They are used to specify elements that do not contain any children or attributes. They are generally mapped to native Java constructs and do not require the generation of special classes to implement them. Enumerated simple types do not result in generated code because they are mapped to Java enum types.
11.1. Primitive Types Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Overview Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
When a message part is defined using one of the XML Schema primitive types, the generated parameter's type is mapped to a corresponding Java native type. The same pattern is used when mapping elements that are defined within the scope of a complex type. The resulting field is of the corresponding Java native type.
Mappings Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Table 11.1, “XML Schema Primitive Type to Java Native Type Mapping” lists the mapping between XML Schema primitive types and Java native types.
| XML Schema Type | Java Type |
|---|---|
| xsd:string | String |
| xsd:integer | BigInteger |
| xsd:int | int |
| xsd:long | long |
| xsd:short | short |
| xsd:decimal | BigDecimal |
| xsd:float | float |
| xsd:double | double |
| xsd:boolean | boolean |
| xsd:byte | byte |
| xsd:QName | QName |
| xsd:dateTime | XMLGregorianCalendar |
| xsd:base64Binary | byte[] |
| xsd:hexBinary | byte[] |
| xsd:unsignedInt | long |
| xsd:unsignedShort | int |
| xsd:unsignedByte | short |
| xsd:time | XMLGregorianCalendar |
| xsd:date | XMLGregorianCalendar |
| xsd:g | XMLGregorianCalendar |
| xsd:anySimpleType [a] | Object |
| xsd:anySimpleType [b] | String |
| xsd:duration | Duration |
| xsd:NOTATION | QName |
[a]
For elements of this type.
[b]
For attributes of this type.
| |
Wrapper classes Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Mapping XML Schema primitive types to Java primitive types does not work for all possible XML Schema constructs. Several cases require that an XML Schema primitive type is mapped to the Java primitive type's corresponding wrapper type. These cases include:
- An
elementelement with itsnillableattribute set totrueas shown:<element name="finned" type="xsd:boolean" nillable="true" /><element name="finned" type="xsd:boolean" nillable="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - An
elementelement with itsminOccursattribute set to0and itsmaxOccursattribute set to1, or itsmaxOccursattribute not specified, as shown :<element name="plane" type="xsd:string" minOccurs="0" />
<element name="plane" type="xsd:string" minOccurs="0" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - An
attributeelement with itsuseattribute set tooptional, or not specified, and having neither itsdefaultattribute nor itsfixedattribute specified, as shown:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Table 11.2, “Primitive Schema Type to Java Wrapper Class Mapping” shows how XML Schema primitive types are mapped into Java wrapper classes in these cases.
| Schema Type | Java Type |
|---|---|
| xsd:int | java.lang.Integer |
| xsd:long | java.lang.Long |
| xsd:short | java.lang.Short |
| xsd:float | java.lang.Float |
| xsd:double | java.lang.Double |
| xsd:boolean | java.lang.Boolean |
| xsd:byte | java.lang.Byte |
| xsd:unsignedByte | java.lang.Short |
| xsd:unsignedShort | java.lang.Integer |
| xsd:unsignedInt | java.lang.Long |
| xsd:unsignedLong | java.math.BigInteger |
| xsd:duration | java.lang.String |