Altova MapForce 2025 Enterprise Edition

The default mapping of XML Schema types to Java data types is as follows:

 

XML Schema

Java

Remarks

xs:string

String


xs:boolean

boolean


xs:decimal

java.math.BigDecimal


xs:float, xs:double

double


xs:integer

java.math.BigInteger


xs:long

long


xs:unsignedLong

java.math.BigInteger

Java does not have unsigned types.

xs:int

int


xs:unsignedInt

long

Java does not have unsigned types.

xs:dateTime, date, time, gYearMonth, gYear, gMonthDay, gDay, gMonth

com.altova.types.DateTime


xs:duration

com.altova.types.Duration


xs:hexBinary and xs:base64Binary

byte[]

Encoding and decoding of binary data is done automatically.

xs:anySimpleType

string


 

All XML Schema types not contained in this list are derived types, and mapped to the same Java type as their respective base type.

 

Generated Classes

For each type in the schema, a class is generated that contains a member for each attribute and element of the type. The members are named the same as the attributes or elements in the original schema (in case of possible collisions, a number is appended). For simple types, assignment and conversion operators are generated. For simple types with enumeration facets, the methods GetEnumerationValue() and SetEnumerationValue(int) can be used together with generated constants for each enumeration value. In addition, the method StaticInfo() allows accessing schema information as one of the following types:

 

com.altova.xml.meta.SimpleType

com.altova.xml.meta.ComplexType

 

Classes generated from complex types include the method SetXsiType(), which enables you to set the xsi:type attribute of the type. This method is useful when you want to create XML instance elements of a derived type.

 

In addition to the classes for the types declared in the XML Schema, a document class (identified with "Doc" below) is generated. It contains all possible root elements as members, and various other methods. For more information about the class, see com.[YourSchema].[Doc].

 

Note:        The actual class name depends on the name of the .xsd schema.

 

For each member attribute or element of a schema type, a new class is generated. For more information about such classes, see:

 

com.[YourSchema].[YourSchemaType].MemberAttribute

com.[YourSchema].[YourSchemaType].MemberElement

 

Note:        The actual class names depend on the name of the schema attribute or element.

 

Error Handling

Errors are reported by exceptions. The following exception classes are defined in the namespace com.altova:

 

Class

Base Class

Description

SourceInstanceUnvailableException

Exception

A problem occurred while loading an XML instance.

TargetInstanceUnavailableException

Exception

A problem occurred while saving an XML instance.

 

In addition, the following Java exceptions are commonly used:

 

Class

Description

java.lang.Error

Internal program logic error (independent of input data)

java.lang.Exception

Base class for runtime errors

java.lang.IllegalArgumentsException

A method was called with invalid argument values, or a type conversion failed.

java.lang.ArithmeticException

Exception thrown when a numeric type conversion fails.

 

Accessing schema information

The generated library allows accessing static schema information via the following classes:

 

com.altova.xml.meta.Attribute

com.altova.xml.meta.ComplexType

com.altova.xml.meta.Element

com.altova.xml.meta.SimpleType

 

The properties that return one of the metadata classes return null if the respective property does not exist.

© 2018-2024 Altova GmbH