We're using Castor XML sourceGen to generate Java code corresponding to an XML schema that has abstract complexTypes and extensions. In our example, the base schema contains a sequence, and the extension class attempts to add a choice to the end of the sequence. We get a validation error if we attempt to add both the element from the base schema and one of the choices from the extension.
Just in case it was a problem with our extension complexType, we also tried wrapping the <choice> in a <sequence>, to make it match the base type. The problem was reproduced with the CVS version as of Dec. 6/2001. <schema targetNamespace="http://www.namespace_check/extensionSchemaTest.xsd" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:nsthree="http://www.namespace_check/extensionSchemaTest.xsd"> <complexType name="ThreeAbstractType" abstract="true"> <sequence> <element name="StringOne" type="string"/> </sequence> </complexType> <element name="Three" type="nsthree:ThreeType"/> <complexType name="ThreeType"> <complexContent> <extension base="nsthree:ThreeAbstractType"> <!-- could start a <sequence> here --> <choice> <element name="StringTwo" type="string"/> <element name="StringThree" type="string"/> </choice> <!-- could end the </sequence> here --> </extension> </complexContent> </complexType> </schema> -------------------------- Main Program: -------------------------- java.io.StringWriter sw = new StringWriter(); Marshaller debugM = new Marshaller((java.io.Writer)(sw)); debugM.setNamespaceMapping("nsthree", "http://www.namespace_check/extensionSchemaTest.xsd"); Three three = new Three(); three.setStringTwo("string two"); three.setStringOne("string one"); debugM.marshal(three); StringBuffer buff = sw.getBuffer(); debug(buff.toString()); -------------------------- GeneratedException: -------------------------- ValidationException: The element 'StringTwo' cannot exist at the same time that element 'StringOne' also exists.; - location of error: XPATH: Three Irving Reid Principal Technical Architect, SelectAccess Baltimore Technologies ----------------------------------------------------------------------------------------------------------------- The information contained in this message is confidential and is intended for the addressee(s) only. If you have received this message in error or there are any problems please notify the originator immediately. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. Baltimore Technologies plc will not be liable for direct, special, indirect or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed on. In addition, certain Marketing collateral may be added from time to time to promote Baltimore Technologies products, services, Global e-Security or appearance at trade shows and conferences. This footnote confirms that this email message has been swept by Baltimore MIMEsweeper for Content Security threats, including computer viruses. ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
