Hi Paul,
The easiest approach is to use an XSLT stylesheet to dynamically modify
the Schema. Simply replace the Union with a string type and this will
allow you to get all the values of your union. You Java class will have
a string type, so you'll have to do your validation of the field to make
sure it's values are correct.
Support for union is definately on our list of planned features.
--Keith
----- Original Message -----
From: "Paul Chisholm" <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
Sent: Tue, 2 Jul 2002 09:13:38 +1000
Subject: Re: [castor-dev] Problems With Source Code Generation
Thanks Scott, I will look into why my generation throws an exception.
On the issue of unsupported features. The system I am building
interfaces to another system via XML and the
XML schema are dictated by the other system. I have no opportunity to
modify the schema to those
supported by Castor. Is there is recommended approach when faced with
this problem.
Paul
----- Original Message -----
From: Scott Venter
To: [EMAIL PROTECTED]
Sent: Tuesday, July 02, 2002 6:49 PM
Subject: Re: [castor-dev] Problems With Source Code Generation
Hi Paul,
I am running version 0.9.3.19 and I have no trouble generating
classes from your first schema.
See attached .zip for classes generated from first schema.
With regards to your second schema you will notice that the stack
trace informs you that the
Data Type union is not yet supported. This is why your simple type
LevelOrVFR which contains
a union of memberTypes="Level VFR" is not created.
[Stack Trace]
-- Suppressing non fatal warnings.
org.xml.sax.SAXException: 'union' elements are not yet supported.
line: 21 at
org.exolab.castor.xml.schema.reader.SaxUnmarshaller.error(SaxUnmarshaller.java:169)
Kind regards
Scott.
----- Original Message -----
From: Paul Chisholm
To: [EMAIL PROTECTED]
Sent: Monday, July 01, 2002 11:56 PM
Subject: [castor-dev] Problems With Source Code Generation
Hi,
I have a couple of problems with source code generation. Using
version 0.9.3.19.
1 - The following schema throws an exception during source
generation.
Schema:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:complexType name="Field19">
<xs:sequence>
<xs:element name="c" minOccurs="0">
<xs:simpleType>
<xs:list itemType="EmergRadioEquip"/>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="EmergRadioEquip">
<xs:restriction base="xs:string">
<xs:enumeration value="U"/>
<xs:enumeration value="V"/>
<xs:enumeration value="E"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
Exception:
Exception in thread "main" java.lang.IllegalArgumentException:
'null' is n
at org.exolab.javasource.JClass.<init>(Unknown Source)
at
org.exolab.castor.builder.TypeConversion.convertType(Unknown So
at
org.exolab.castor.builder.MemberFactory.createFieldInfo(Unknown
at
org.exolab.castor.builder.SourceFactory.processContentModel(Unk
at
org.exolab.castor.builder.SourceFactory.processContentModel(Unk
at
org.exolab.castor.builder.SourceFactory.processComplexType(Unkn
at
org.exolab.castor.builder.SourceFactory.createSourceCode(Unknow
at
org.exolab.castor.builder.SourceGenerator.processComplexType(Un
at
org.exolab.castor.builder.SourceGenerator.createClasses(Unknown
at
org.exolab.castor.builder.SourceGenerator.generateSource(Unknow
at
org.exolab.castor.builder.SourceGenerator.generateSource(Unknow
at
org.exolab.castor.builder.SourceGenerator.generateSource(Unknow
at
org.exolab.castor.builder.SourceGenerator.main(Unknown Source)
2 - The following schema generates classes for 'Test' and
'VFR' but not 'Level' and
'LevelOrVFR'. No error is reported during generation.
javaclassmapping=type.
Compilation fails because class 'Test' has references to the
non-existent class
'LevelOrVFR'.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xs:complexType name="Test">
<xs:sequence>
<xs:element name="level" type="LevelOrVFR"/>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="Level">
<xs:restriction base="xs:string">
<xs:pattern value="(A|F)[0-9]{3}"/>
<xs:pattern value="(S|M)[0-9]{4}"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="VFR">
<xs:restriction base="xs:string">
<xs:enumeration value="VFR"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="LevelOrVFR">
<xs:union memberTypes="Level VFR"/>
</xs:simpleType>
</xs:schema>
Thanks,
Paul
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev