|  |  |  | License Codehaus OpenEJB OpenJMS OpenORB Tyrex

Old releases
General
Release 1.3
Release 1.3rc1
Release 1.2

Main
Home
About
Features
Download
Dependencies
Reference guide
Publications
JavaDoc
Maven 2 support
Maven 2 archetypes
DTD & Schemas
Recent HTML changes
News Archive
RSS news feed
Project Wiki

Development/Support
Mailing Lists
SVN/JIRA
Contributing
Support
Continuous builds
Prof. services

Related projects
Spring ORM support
Spring XML factories
WS frameworks

XML
XML

XML Code Generator
XML Code Generator

JDO
Introduction
First steps
Using JDO
JDO Config
Types
JDO Mapping
JDO FAQ
JDO Examples
JDO HOW-TOs
Tips & Tricks
Other Features
JDO sample JAR

Tools
Schema generator

Advanced JDO
Caching
OQL
Trans. & Locks
Design
KeyGen
Long Trans.
Nested Attrs.
Pooling Examples
LOBs
Best practice

DDL Generator
Using DDL Generator
Properties
Ant task
Type Mapping

More
The Examples
3rd Party Tools
JDO Tests
XML Tests
Configuration

About
License
User stories
Contributors
Marketplace
Status, Todo
Changelog
Library
Contact
Project Name

## Castor Source Generator XML Schema Support

Documentation Author(s):
Arnaud Blandin
Edward Kuns

Introduction
Supported XML Schema Built-in Datatypes
Primitive Datatypes
Derived Datatypes
Supported XML Schema Structures
Groups
Wildcard

## Introduction

Castor XML supports the W3C XML Schema 1.0 Second Edition Recommendation document (10/28/2004). The Schema Object Model (located in the package org.exolab.castor.xml.schema) provides an in-memory representation of a given XML schema whereas the Source Generator provides a binding between XML schema datatypes and structures into the corresponding ones in Java.

The Castor Schema Object Model can read (org.exolab.castor.xml.schema.reader) and write (org.exolab.castor.xml.schema.writer) an XML Schema as defined by the W3C recommandation. It allows you to create and manipulate an in-memory view of an XML Schema.

The Castor Schema Object Model supports the W3C XML Schema recommendation with no limitation. However the Source Generator does currently not offer a one to one mapping from an XML Schema component to a Java component for every XML Schema components; some limitations exist. The aim of the following sections is to provide a list of supported features in the Source Generator. Please keep in mind that the Castor Schema Object Model again can handle any XML Schema without limitations.

Some Schema types do not have a corresponding type in Java. Thus the Source Generator uses Castor implementation of these specific types (located in the types package). For instance the `duration` type is implemented directly in Castor. Remember that the representation of XML Schema datatypes does not try to fit the W3C XML Schema specifications exactly. The aim is to map an XML Schema type to the Java type that is the best fit to the XML Schema type.

You will find next a list of the supported XML Schema datatypes and structures in the Source Code Generator. For a more detailed support of XML Schema structure and more information on the Schema Object Model, please refer to Source Generator User Document (PDF).

## Supported XML Schema Built-in Datatypes

The following is a list of the supported datatypes with the corresponding facets and the Java mapping type.

### Primitive Datatypes

XML Schema Type | Supported Facets | Java mapping type
--- | --- | ---
anyURI | enumeration | `java.lang.String`
base64Binary |  | primitive `byte[]`
boolean | pattern | primitive `boolean` or `java.lang.Boolean` 2
date | enumeration maxInclusive maxExclusive minInclusive minExclusive pattern whitespace1 | `org.exolab.castor.types.Date`
dateTime | enumeration maxInclusive maxExclusive minInclusive minExclusive pattern whitespace1 | `java.util.Date`
decimal | totalDigits fractionDigits pattern whiteSpace enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `java.math.BigDecimal`
double | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `double` or `java.lang.Double` 2
duration | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.Duration`
float | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `float` or `java.lang.Float` 2
gDay | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.GDay`
gMonth | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.GMonth`
gMonthDay | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.GMonthDay`
gYear | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.GYear`
gYearMonth | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.GYearMonth`
hexBinary |  | primitive `byte[]`
QName | length minLength maxLength pattern enumeration | `java.lang.String`
string | length minLength maxLength pattern enumeration whiteSpace | `java.lang.String`
time | pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `org.exolab.castor.types.Time`

### Derived Datatypes

Type | Supported Facets | Java mapping type
--- | --- | ---
byte | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `byte` or `java.lang.Byte` 2
ENTITY |  | Not implemented
ENTITIES |  | Not implemented
ID | enumeration | `java.lang.String`
IDREF |  | `java.lang.Object`
IDREFS |  | `java.util.Vector` of `java.lang.Object`
int | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `int` or `java.lang.Integer` 2
integer | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
language | length minLength maxLength pattern enumeration whiteSpace | treated as a `xsd:string` 3
long | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
Name |  | Not implemented
NCName | enumeration | `java.lang.String`
negativeInteger | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
NMTOKEN | enumeration length maxlength minlength | `java.lang.String`
NMTOKENS |  | `java.util.Vector` of `java.lang.String`
NOTATION |  | Not implemented
nonNegativeInteger | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
nonPositiveInteger | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
normalizedString | enumeration length minLength maxLength pattern | `java.lang.String`
positiveInteger | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `long` or `java.lang.Long` 2
short | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `short` or `java.lang.Short` 2
token | length minLength maxLength pattern enumeration whiteSpace | treated as a `xsd:string` 3
unsignedByte | totalDigits fractionDigits4 maxExclusive minExclusive maxInclusive minInclusive pattern whitespace1 | primitive `short` or `java.lang.Short` 2
unsignedInt | totalDigits fractionDigits4 maxExclusive minExclusive maxInclusive minInclusive pattern whitespace1 | primitive `long` or `java.lang.Long` 2
unsignedLong | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | `java.math.BigInteger`
unsignedShort | totalDigits fractionDigits4 pattern enumeration maxInclusive maxExclusive minInclusive minExclusive whitespace1 | primitive `int` or `java.lang.Integer` 2

Notes:

1 For the date/time and numeric types, the only supported value for whitespace is "collapse".

2 For the various numerical types, the default behavior is to generate primitive types. However, if the use of wrappers is enabled by the following line in the `castorbuilder.properties` file:

    org.exolab.castor.builder.primitivetowrapper=true

then the `java.lang.*` wrapper objects (as specified above) will be used instead.

3 Currently, xsd:language and xsd:token are treated as if they were xsd:string.

4 For the integral types, the only allowed value for fractionDigits is 0.

## Supported XML Schema Structures

Supporting XML schema structures is a constant work. The main structures are already supported with some limitations. The following will give you a rough list of the supported structures. For a more detailed support of XML Schema structure in the Source Generator or in the Schema Object Model, please refer to Source Generator User Document (PDF).

Supported schema components:

- | Attribute Declaration (`<attribute>`)
- | Element Declaration (`<element>`)
- | ComplexType Definition (`<complexType>`)
- | AttributeGroup Definition (`<attributeGroup>`)
- | ModelGroup Definition (`<group>`)
- | ModelGroup (`<all>`, `<choice>`, `<sequence>`)
- | Annotation (`<annotation>`)
- | Wildcard (`<any>`)
- | SimpleType Definition (`<simpleType>`)

### Groups

Grouping support covers both Model Group Definitions (`<group>`) and Model Groups (`<all>`, `<choice>`, `<sequence>`). In this section we will label as a 'nested group' any Model Group whose first parent is another Model Group.

- | For each top-level Model Group Definition, a class is generated either when using the 'element' mapping property or the 'type' one.
- | If a group -- nested or not -- appears to have maxOccurs > 1 then a class is generated to represent the items contained in the group.

-

For each nested group, a class is generated. The name of the generated class will follow this naming convention: `Name,Compositor+,Counter?` where

- | 'Name' is name of the top-level component (element, complexType or group).
- | 'Compositor' is the compositor of the nested group. For instance, if a 'choice' is nested inside a sequence, the value of Compositor will be `SequenceChoice` ('Sequence'+'Choice'). Note: if the 'choice' is inside a Model Group and that Model Group parent is a Model Group Definition or a complexType then the value of'Compositor' will be only 'Choice'.
- | 'Counter' is a number that prevents naming collision.

### Wildcard

`<any>` is supported in the Source Generator and will map to an AnyNode. However full namespace validation is not yet implemented even though an AnyNode structure is fully namespace aware.

`<anyAttribute>` is currently not supported. It is a work in progress.

<notice> Copyright © 1999-2005 ExoLab Group, Intalio Inc., and Contributors. All rights reserved. </notice>
<notice> Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners. </notice>