I use Castor 0.9.5 source generator with default settings to create java
classes from the following XSD (complete XSD see attachment)
<xs:element name="IB_ApplicationParameters"
type="ibr:IB_ApplicationParametersType">
</xs:element>
<xs:complexType name="IB_ApplicationParametersType">
<xs:sequence>
<xs:element name="TimeElement" type="xs:time" minOccurs="0"
default="00:00:00"/>
<xs:element name="DurationElement" type="xs:duration"
minOccurs="0"
default="P1W"/>
<xs:element name="DateTimeelement" type="xs:dateTime"
minOccurs="0"
default="2003-10-30T12:00:00Z"/>
</xs:sequence>
</xs:complexType>
The initialization of the three elements leads to java exceptions when
compiling the generated java classes, since java of course understands the
initializers as variable identifiers not constants.
/**
* Field _timeElement
*/
private org.exolab.castor.types.Time _timeElement = 00:00:00;
/**
* Field _durationElement
*/
private org.exolab.castor.types.Duration _durationElement = P1W;
/**
* Field _dateTimeelement
*/
private java.util.Date _dateTimeelement = 2003-10-30T12:00:00Z;
Is this a bug or do I have to change my XSD so the source generator produces
correct initialization code?
Thanks, Ulf
--
NEU F�R ALLE - GMX MediaCenter - f�r Fotos, Musik, Dateien...
Fotoalbum, File Sharing, MMS, Multimedia-Gru�, GMX FotoService
Jetzt kostenlos anmelden unter http://www.gmx.net
+++ GMX - die erste Adresse f�r Mail, Message, More! +++<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.test.de/ibr" xmlns:ibr="http://www.test.de/ibr" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<!-- -->
<xs:element name="IB_ApplicationParameters" type="ibr:IB_ApplicationParametersType">
</xs:element>
<!-- -->
<xs:complexType name="IB_ApplicationParametersType">
<xs:sequence>
<xs:element name="TimeElement" type="xs:time" minOccurs="0" default="00:00:00"/>
<xs:element name="DurationElement" type="xs:duration" minOccurs="0" default="P1W"/>
<xs:element name="DateTimeelement" type="xs:dateTime" minOccurs="0" default="2003-10-30T12:00:00Z"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
/*
* This class was automatically generated with
*
Castor 0.9.4.3, using an XML
* Schema.
* $Id$
*/
package ibr.test.appvarcastorbug;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;
/**
* Class IB_ApplicationParameters.
*
* @version $Revision$ $Date$
*/
public class IB_ApplicationParameters extends IB_ApplicationParametersType
implements java.io.Serializable
{
//----------------/
//- Constructors -/
//----------------/
public IB_ApplicationParameters() {
super();
} //-- ibr.test.appvarcastorbug.IB_ApplicationParameters()
//-----------/
//- Methods -/
//-----------/
/**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid()
/**
* Method marshal
*
* @param out
*/
public void marshal(java.io.Writer out)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, out);
} //-- void marshal(java.io.Writer)
/**
* Method marshal
*
* @param handler
*/
public void marshal(org.xml.sax.ContentHandler handler)
throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
Marshaller.marshal(this, handler);
} //-- void marshal(org.xml.sax.ContentHandler)
/**
* Method unmarshal
*
* @param reader
*/
public static ibr.test.appvarcastorbug.IB_ApplicationParameters unmarshal(java.io.Reader reader)
throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
{
return (ibr.test.appvarcastorbug.IB_ApplicationParameters) Unmarshaller.unmarshal(ibr.test.appvarcastorbug.IB_ApplicationParameters.class, reader);
} //-- ibr.test.appvarcastorbug.IB_ApplicationParameters unmarshal(java.io.Reader)
/**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate()
}
/*
* This class was automatically generated with
*
Castor 0.9.4.3, using an XML
* Schema.
* $Id$
*/
package ibr.test.appvarcastorbug;
//---------------------------------/
//- Imported classes and packages -/
//---------------------------------/
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.util.Date;
import org.exolab.castor.types.Duration;
import org.exolab.castor.types.Time;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
/**
* Class IB_ApplicationParametersType.
*
* @version $Revision$ $Date$
*/
public abstract class IB_ApplicationParametersType implements java.io.Serializable {
//--------------------------/
//- Class/Member Variables -/
//--------------------------/
/**
* Field _timeElement
*/
private org.exolab.castor.types.Time _timeElement = 00:00:00;
/**
* Field _durationElement
*/
private org.exolab.castor.types.Duration _durationElement = P1W;
/**
* Field _dateTimeelement
*/
private java.util.Date _dateTimeelement = 2003-10-30T12:00:00Z;
//----------------/
//- Constructors -/
//----------------/
public IB_ApplicationParametersType() {
super();
try {
setTimeElement(00:00:00);
} catch (java.text.ParseException pe) {
throw new IllegalStateException(pe.getMessage());
}
try {
setDurationElement(P1W);
} catch (java.text.ParseException pe) {
throw new IllegalStateException(pe.getMessage());
}
try {
setDateTimeelement(2003-10-30T12:00:00Z);
} catch (java.text.ParseException pe) {
throw new IllegalStateException(pe.getMessage());
}
} //-- ibr.test.appvarcastorbug.IB_ApplicationParametersType()
//-----------/
//- Methods -/
//-----------/
/**
* Returns the value of field 'dateTimeelement'.
*
* @return the value of field 'dateTimeelement'.
*/
public java.util.Date getDateTimeelement()
{
return this._dateTimeelement;
} //-- java.util.Date getDateTimeelement()
/**
* Returns the value of field 'durationElement'.
*
* @return the value of field 'durationElement'.
*/
public org.exolab.castor.types.Duration getDurationElement()
{
return this._durationElement;
} //-- org.exolab.castor.types.Duration getDurationElement()
/**
* Returns the value of field 'timeElement'.
*
* @return the value of field 'timeElement'.
*/
public org.exolab.castor.types.Time getTimeElement()
{
return this._timeElement;
} //-- org.exolab.castor.types.Time getTimeElement()
/**
* Method isValid
*/
public boolean isValid()
{
try {
validate();
}
catch (org.exolab.castor.xml.ValidationException vex) {
return false;
}
return true;
} //-- boolean isValid()
/**
* Sets the value of field 'dateTimeelement'.
*
* @param dateTimeelement the value of field 'dateTimeelement'.
*/
public void setDateTimeelement(java.util.Date dateTimeelement)
{
this._dateTimeelement = dateTimeelement;
} //-- void setDateTimeelement(java.util.Date)
/**
* Sets the value of field 'durationElement'.
*
* @param durationElement the value of field 'durationElement'.
*/
public void setDurationElement(org.exolab.castor.types.Duration durationElement)
{
this._durationElement = durationElement;
} //-- void setDurationElement(org.exolab.castor.types.Duration)
/**
* Sets the value of field 'timeElement'.
*
* @param timeElement the value of field 'timeElement'.
*/
public void setTimeElement(org.exolab.castor.types.Time timeElement)
{
this._timeElement = timeElement;
} //-- void setTimeElement(org.exolab.castor.types.Time)
/**
* Method validate
*/
public void validate()
throws org.exolab.castor.xml.ValidationException
{
org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
validator.validate(this);
} //-- void validate()
}