Hi, I have an XML schema that declares a complexType (BEHAVIOR-RULES), which includes a reference to an abstract element (BEHAVIOR-RULES) in a xs:sequence. It also declares two other elements (FILE-UPLOAD, RUN-SCRIPT) as subtitutes for this abstract element. And finally another complexType is declared (SYSTEM-BEHAVIOR-RULE), which is derived by extension from BEHAVIOR-RULES.
The schema (excerpt) looks like this: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="BEHAVIOR-RULES" abstract="true"/> <xs:complexType name="BEHAVIOR-RULES"> <xs:sequence> <xs:element ref="BEHAVIOR-RULES"/> </xs:sequence> </xs:complexType> <xs:element name="SYSTEM-BEHAVIOR-RULE"> <xs:complexType> <xs:complexContent> <xs:extension base="BEHAVIOR-RULES"> <xs:attribute name="_TXN-SUPPORTED_" fixed="DELETE"/> <xs:attribute name="_KEY_" fixed="_CHILD_::_KEY_"/> <xs:attribute name="_CONTAINER_" fixed="SYSTEM-BEHAVIOR-RULE-TABLE"/> </xs:extension> </xs:complexContent> </xs:complexType> </xs:element> <xs:element name="FILE-UPLOAD" substitutionGroup="BEHAVIOR-RULES"> <xs:complexType> <xs:attribute name="name" use="required"/> [...] </xs:complexType> </xs:element> <xs:element name="RUN-SCRIPT" substitutionGroup="BEHAVIOR-RULES"> <xs:complexType> <xs:attribute name="name" use="required"/> [...] </xs:complexType> </xs:element> </xs:schema> Using this as input, generateDS writes SYSTEM_BEHAVIOR_RULE as a subclass of BEHAVIOR_RULES. However this leads to an error when the constructor of the superclass is called with additional arguments (BEHAVIOR_RULES): [...] File "/tmp/generateds_api.py", line 31480, in factory return SYSTEM_BEHAVIOR_RULE(*args_, **kwargs_) File "/tmp/generateds_api.py", line 31472, in __init__ super(SYSTEM_BEHAVIOR_RULE, self).__init__(BEHAVIOR_RULES, ) TypeError: __init__() takes exactly 1 argument (2 given) I have seen this problem whenever xs:extension is used in such a way. I can work around it if I slightly change the schema so as to avoid deriving by extension, which means removing the BEHAVIOR-RULES complexType and rewriting SYSTEM-BEHAVIOR-RULE like this: <xs:element name="SYSTEM-BEHAVIOR-RULE"> <xs:complexType> <xs:sequence> <xs:element ref="BEHAVIOR-RULES"/> </xs:sequence> <xs:attribute name="_TXN-SUPPORTED_" fixed="DELETE"/> <xs:attribute name="_KEY_" fixed="_CHILD_::_KEY_"/> <xs:attribute name="_CONTAINER_" fixed="SYSTEM-BEHAVIOR-RULE-TABLE"/> </xs:complexType> </xs:element> However there is a further complication in this case, due to the abstract element. The generated code does not seem to somehow link the abstract element with its' substitutes, so when such nodes are present in the (parsed) input, they are not preserved in the (exported) output, and of course this breaks validation. <SYSTEM-BEHAVIOR-RULE-TABLE> - <SYSTEM-BEHAVIOR-RULE> - <FILE-UPLOAD name="..." [...]/> - </SYSTEM-BEHAVIOR-RULE> + <SYSTEM-BEHAVIOR-RULE/> </SYSTEM-BEHAVIOR-RULE-TABLE> I can overcome the problem if I replace the xs:sequence in the above with an xs:choice containing references to the elements that provide substitutes for BEHAVIOR-RULES. My question is however if generateDS should be able to handle the original schema or not. Having read about element extensions and substitution groups in the documentation, I would tend to say yes, but I am not sure. For the record, this schema is produced by trang (http://www.thaiopensource.com/relaxng/trang.html), which converts from the following DTD (excerpt): <!ENTITY % BEHAVIOR-RULES "(FILE-UPLOAD|RUN-SCRIPT)"> <!ELEMENT SYSTEM-BEHAVIOR-RULE (%BEHAVIOR-RULES;)> <!ATTLIST SYSTEM-BEHAVIOR-RULE _TXN-SUPPORTED_ (DELETE|SET|GET) #FIXED "DELETE" _KEY_ CDATA #FIXED "_CHILD_::_KEY_" _CONTAINER_ CDATA #FIXED "SYSTEM-BEHAVIOR-RULE-TABLE" > <!ELEMENT FILE-UPLOAD EMPTY> <!ATTLIST FILE-UPLOAD name CDATA #REQUIRED [...] > <!ELEMENT RUN-SCRIPT EMPTY> <!ATTLIST RUN-SCRIPT name CDATA #REQUIRED [...] > Thanks for your insight. Regards, Zenon Mousmoulas ------------------------------------------------------------------------------ Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server from Actuate! Instantly Supercharge Your Business Reports and Dashboards with Interactivity, Sharing, Native Excel Exports, App Integration & more Get technology previously reserved for billion-dollar corporations, FREE http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk _______________________________________________ generateds-users mailing list generateds-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/generateds-users