Ralf, just managed to unmarshal the following XML instance against the classes generated with the XML code generator (using 'type' mode, though).
<?xml version="1.0" encoding="UTF-8"?> <StrategyTest> <Input xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="String"> <Svalue>Test</Svalue> </Input> </StrategyTest> Please note the additional attribute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" on the <Input> element. I hope this helps. Werner PS In case this is not clear, I have *not* used the mapping file Ralf Rausch wrote: > Dear Castor Users, > > > > I created the below-mentioned xml files. And when I run my application > I will get the following exception: > > > > unable to add 'Input' to <StrategyTest> due to the following exception: > >>>>--- Begin Exception ---<<< > > java.lang.IllegalArgumentException: Type conversion error: could not set > value of input(com.brox.rrausch.Input) with value of type > com.brox.rrausch.String > > > > Can you please tell me what I’m doing wrong??? > > > > > > > > ---------------------------------------------------------------- > > > > My mapping file looks like: > > > > > > <?xml version="1.0" encoding="UTF-8"?> > > <!DOCTYPE mapping PUBLIC "-//EXOLAB/Castor Mapping DTD Version 1.0//EN" > "http://castor.org/mapping.dtd"> > > <mapping> > > <class name="com.brox.rrausch.StrategyTest"> > > <map-to xml="StrategyTest"/> > > <field name="input" > type="com.brox.rrausch.Input" get-method="getInput" set-method="setInput"> > > <bind-xml name="Input" > type="InformationValue" node="element"/> > > </field> > > </class> > > <class name="com.brox.rrausch.InformationValue"> > > <map-to xml="InformationValue"/> > > <field name="ivalueList" type="java.lang.Object" > collection="arraylist" get-method="getIvalue" set-method="setIvalue"> > > <bind-xml name="Ivalue" node="element"/> > > </field> > > </class> > > <class name="com.brox.rrausch.Input" > extends="com.brox.rrausch.InformationValue"> > > <map-to xml="Input"/> > > </class> > > <class name="com.brox.rrausch.String" > extends="com.brox.rrausch.InformationValue"> > > <map-to xml="String"/> > > <field name="svalue" type="java.lang.String" > get-method="getSvalue" set-method="setSvalue"> > > <bind-xml name="Svalue" node="element"/> > > </field> > > </class> > > </mapping> > > > > > > --------------------------------------------------------------------------------------------------------- > > > > > > My XSD file looks like: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <xs:schema> > > <xs:element name="StrategyTest"> > > <xs:annotation> > > <xs:documentation>Comment describing > your root element</xs:documentation> > > </xs:annotation> > > <xs:complexType> > > <xs:sequence> > > <xs:element name="Input" > type="InformationValue" minOccurs="0"/> > > </xs:sequence> > > </xs:complexType> > > </xs:element> > > <xs:complexType name="InformationValue" abstract="true"> > > <xs:sequence> > > <xs:element name="Ivalue" > maxOccurs="unbounded"/> > > </xs:sequence> > > </xs:complexType> > > <xs:complexType name="String"> > > <xs:annotation> > > <xs:documentation>String > Parameter</xs:documentation> > > </xs:annotation> > > <xs:complexContent> > > <xs:restriction base="InformationValue"> > > <xs:sequence> > > <xs:element > name="Svalue"> > > > <xs:simpleType> > > > > <xs:restriction base="xs:string"/> > > > </xs:simpleType> > > </xs:element> > > </xs:sequence> > > </xs:restriction> > > </xs:complexContent> > > </xs:complexType> > > </xs:schema> > > > > ----------------------------------------------------------------------------------------------------------------------------------------------------------------- > > > > My xml file to unmarshal: > > > > <?xml version="1.0" encoding="UTF-8"?> > > <StrategyTest> > > <Input xsi:type="String"> > > <Svalue>Test</Svalue> > > </Input> > > </StrategyTest> > > > > > > > > > > > > Thanks and regards, > > > > Ralf > --------------------------------------------------------------------- To unsubscribe from this list please visit: http://xircles.codehaus.org/manage_email

