Hi,

I haved used castor to generate the java class for my xml shcema.

When I use these code to Unmarshel a XML file and Marshel to a XML
file, the result is different and not valid (missing the xsi:type).

It is really simple xsd. Could anyone have a look this example.

############# XSD ##################################
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema";>
        <xs:element name="Root" type="Root"/>
        <xs:complexType name="Root">
                <xs:sequence>
                        <xs:element name="OptionPayoffStyle" 
type="OptionPayoffStyle"
nillable="true"/>
                </xs:sequence>
        </xs:complexType>
        <xs:complexType name="OptionPayoffStyle" abstract="true">
                <xs:simpleContent>
                        <xs:extension base="xs:string"/>
                </xs:simpleContent>
        </xs:complexType>
        <xs:complexType name="CallPut">
                        <xs:simpleContent>
                        <xs:restriction base="OptionPayoffStyle">
                                <xs:enumeration value="Call"/>
                                <xs:enumeration value="Put"/>
                        </xs:restriction>
                </xs:simpleContent>
        </xs:complexType>
</xs:schema>

############### XML Source #################################
<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSPY v2004 rel. 4 U
(http://www.xmlspy.com)-->
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xsi:noNamespaceSchemaLocation="F:\dataBinding\FXOTMSUAT\SmallTest.xsd">
        <gmt:OptionPayoffStyle xsi:type="CallPut">Call</gmt:OptionPayoffStyle>
</Root>

################ XML Result ##################################

<?xml version="1.0" encoding="UTF-8"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="Root">
        <OptionPayoffStyle>Call</OptionPayoffStyle>
</Root>
#############################################################



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

Reply via email to