Title: RE: [castor-dev] Marshalling attributes problem...

The latest CVS version does fix the problem with attributes being placed in the wrong class as described below.  However I encounter other problems when loading my mapping file.

I get an InstantiationException (org.exolab.castor.mapping.loader.Types.java method newInstance())when castor tries to load my mapping file.  Castor complains that it can't call the constructor method.  The reason for this:

in my XML schema file I have
        <xsd:simpleType name="endPtType">
                <xsd:restriction base="xsd:string">
                        <xsd:enumeration value="Originating"/>
                        <xsd:enumeration value="Destination"/>
                </xsd:restriction>
        </xsd:simpleType>

However SourceGenerator does not produce public constructor for this class.  Instead SourceGenerator produces private constructor.

Has this problem been fixed or is there something new that I am not aware of.
Regards,
HC.


-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, November 21, 2001 7:29 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Marshalling attributes problem...



Hi Henry,

see inline...

> Henry Chin wrote:
>
> Hi,
>   I have in my schema file the following complexType
>
>    <xs:complexType name="ProgramType">
>       <xs:choice maxOccurs="unbounded">
>          <xs:element name="add"          type="actionType"
> minOccurs="0"/>
>          <xs:element name="delete"       type="deleteType"
> minOccurs="0"/>
>          <xs:element name="redeploy"     type="actionType"
> minOccurs="0"/>
>          <xs:element name="update"       type="actionType"
> minOccurs="0"/>
>       </xs:choice>
>       <xs:attribute name="version" type="VersionType" use="required"/>
>
>    </xs:complexType>
>
> When I marshal my object out to XML, the version attribute is not
> shown.  I found out that the SourceGenerator creates two classes (and
> the associated descriptor classes) called ProgramType.java and
> ProgramTypeItem.java.  My attribute "version" is located inside
> ProgramTypeItem.java.  From a descriptor perspective
> ProgramTypeItem.java is considered to be a container (set to true).
> The marshaller does not output objects that are containers.

I haven't had a chance to verify your bug yet, but the version attribute
should definately appear in ProgramType and not ProgramTypeItem.

Which version are you using? If you are using the CVS version then it's
a definate bug which still needs to be fixed.

>
> Is there a way to get around this problem so that either:
> 1) SourceGenerator creates the "version" attribute inside
> ProgramType.java and not ProgramTypeItem.java.  I would think this
> would be easier.

This is the correct approach.

>
> 2) To change the marshaller so that container objects are created.
> However, I think this would cause more problems.

This is not a good idea as it would lead to incorrect behavior.

Thanks,

--Keith

-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to