Hi,
I'm using the SourceGenerator of Castor 1.0 as of 2006-04-06.
When trying to generate the Java source code for the following
schema:
<?xml version="1.0" encoding="UTF-8"?>
<!-- SourceGenerator ends up in infinite loop -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://foo.com/bar/common"
targetNamespace="http://foo.com/bar/xsd">
<xs:complexType name="aggregate-type-1">
<xs:sequence>
<xs:element name="component" type="component"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="aggregate-type-2">
<xs:sequence>
<xs:element name="component" type="component"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="component">
<xs:sequence>
<xs:element name="object" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
the SourceGenerator ends up in an infinite loop in method
org.exolab.castor.builder.SourceFactory.createUnmarshalMethods.
What I observed is that using the same name twice for an element
and a complexType messes up Castors internal class hierarchy held
in JClass instances, since at generating the code for the complexType
named `component', the corresponding JClass instance' superclass
name points towards `component' again, and so the inifinite loop
starts.
Renaming the elements to some unique name or using only one of
the aggregate types, this error does not happen (both workarounds
are out of scope for my project), i.e. for the following schema,
the SourceGenerator terminates and correct code is generated:
<?xml version="1.0" encoding="UTF-8"?>
<!-- SourceGenerator works -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns="http://foo.com/bar/common"
targetNamespace="http://foo.com/bar/xsd">
<xs:complexType name="aggregate-type-1">
<xs:sequence>
<xs:element name="component" type="component"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="component">
<xs:sequence>
<xs:element name="object" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
This error not observed for castor-1.0M1 (and presumably for all versions
before 1.0M1).
Any help in form of a bug fix is appreciated.
Viele Grüße,
Heiko
Title: [XML] Bug in SourceGenerator: Same element and complexType names lead to infinite loop