castor
  1. castor
  2. CASTOR-1146

can't generate proper java classes for redefined complexType

    Details

    • Type: Bug Bug
    • Status: Reopened Reopened
    • Priority: Blocker Blocker
    • Resolution: Unresolved
    • Affects Version/s: 0.9.6
    • Fix Version/s: None
    • Component/s: XML code generator
    • Labels:
      None
    • Number of attachments :
      1

      Description

      snippet of generated BodyType.java

      ...
      public class BodyType extends BodyType // <----- bug implements java.io.Serializable { ...

      base.xsd

      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified"

      attributeFormDefault="unqualified">
      <xs:annotation>
      <xs:documentation>base schema</xs:documentation>
      </xs:annotation>
      <xs:element name="Document">
      <xs:complexType>
      <xs:sequence>
      <xs:element name="Body" type="BodyType"/>
      </xs:sequence>
      </xs:complexType>
      </xs:element>
      <xs:complexType name="BodyType">
      <xs:sequence>
      <xs:any namespace="##any" processContents="lax" minOccurs="0"
      maxOccurs="unbounded"/>
      </xs:sequence>
      </xs:complexType>
      </xs:schema>

      redefined.xsd(redefine complexType "BodyType" in above base.xsd)

      <?xml version="1.0" encoding="UTF-8"?>
      <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
      elementFormDefault="qualified"

      attributeFormDefault="unqualified">
      <xs:redefine schemaLocation="base.xsd">
      <!-- yes, BodyType will be redefined here -->
      <xs:complexType name="BodyType">
      <xs:complexContent>
      <!-- BodyType in base.xsd -->
      <xs:restriction base="BodyType">
      <xs:sequence>
      <xs:element name="AccountName">
      <xs:annotation>
      <xs:documentation>account name</xs:documentation>
      </xs:annotation>
      <xs:simpleType>
      <xs:restriction base="xs:string">
      <xs:maxLength value="20"/>
      </xs:restriction>
      </xs:simpleType>
      </xs:element>
      <xs:element name="Password">
      <xs:annotation>
      <xs:documentation>password</xs:documentation>
      </xs:annotation>
      <xs:simpleType>
      <xs:restriction base="xs:string">
      <xs:maxLength value="20"/>
      </xs:restriction>
      </xs:simpleType>
      </xs:element>
      </xs:sequence>
      </xs:restriction>
      </xs:complexContent>
      </xs:complexType>
      </xs:redefine>
      </xs:schema>

      Work Around

      RCS file:
      /home/projects/castor/scm/castor/src/main/org/exolab/castor/builder/SourceFactory.java,v
      retrieving revision 1.16
      diff -r1.16 SourceFactory.java
      1383c1383,1384
      < if (! ( complexType.isRestricted() &&
      ((ComplexType)base).isSimpleContent() ) )

      > if (! ( complexType.isRestricted() &&
      ((ComplexType)base).isSimpleContent() )
      > && !state.jClass.getName().equals(baseClassName))

      BTW, I've checked the newest version of SourceFactory.java and the bug still exist.

      Sorry for that bugzilla post(bug 1938) and thank you keith for correcting me

        Activity

          People

          • Assignee:
            Unassigned
            Reporter:
            Dureek Wu
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated: