i working on project involving java back-end delphi front-end. attempting generate xml bindings based off of .xsd in java. xsd contains object called tasklist has item tasks. tasks list of task. when generate xml bindings delphi attempts createcollection() function using txmltasklist throws error because txmltasklist ixmlnode instead of ixmlnodecollection.
i still new using xsd files , xml bindings generation feature based off of little understand assuming since tasklist contains single object tasks should not getting used in createcollection function, instead think tasks list of task should getting used.
this line xml bindings file throwing error on:
fexportonclientchange := createcollection(txmltasklist, ixmltask, 'exportonclientchange') ixmltasklist;
this txmltasklisk, showing txmlnode instead of txmlnodecollectionclass createcollection looking for.
type txmltasklist = class(txmlnode, ixmltasklist) protected { ixmltasklist } function get_tasks: ixmltasks; public procedure afterconstruction; override; end;
in attemps figure out problem did notice if make tasklist unbounded list of tasks , leave tasks unbounded list of task generates fine in delphi xml file, mean have list of list not wanting.
one thing might hard tell here tasklist , tasks in different xsd files although linked.
<complextype name="tasklist"> <sequence> <element name="tasks" type="struct:tasks"></element> </sequence> </complextype> <complextype name="tasks"> <sequence> <element ref="struct:task" maxoccurs="unbounded" minoccurs="0"></element> </sequence> </complextype>
you on own in delphi department.
with said, use xjc , xsd files generate java classes.
it looks included in question sample of xsd know wrong. in xsd sample have sequence of sequences - i'd expect sample generate class collection of collections of task objects.
if understand question correctly want tasklist contain collection of tasks. shouldn't hard. have tried?
here example of how generate thresholds object contains list of individual threshold objects:
<xsd:element name="thresholds" type="thresholdstype"/> <xsd:complextype name ="thresholdstype"> <xsd:sequence> <xsd:element ref="threshold" maxoccurs="unbounded" minoccurs="0"/> </xsd:sequence> <xsd:attribute name="interpolate" type="xsd:string" use="optional" /> <xsd:attribute name="parameter" type="xsd:string" use="optional" /> <xsd:attribute name="unitsystem" type="xsd:string" use="optional" /> </xsd:complextype> <xsd:element name="threshold" type="thresholdtype"/> <xsd:complextype name="thresholdtype"> <xsd:simplecontent> <xsd:extension base="xsd:string"> <xsd:attribute type="xsd:string" name="id" use="optional"/> <xsd:attribute type="xsd:double" name="mininclusive" use="optional"/> <xsd:attribute type="xsd:double" name="maxexclusive" use="optional"/> </xsd:extension> </xsd:simplecontent> </xsd:complextype>
here start of generated thresholdstype java class:
@xmlaccessortype(xmlaccesstype.field) @xmltype(name = "thresholdstype", proporder = { "threshold" }) @javax.xml.bind.annotation.xmlrootelement(name="thresholdstype implements cloneable, named, visitable, copyto, equals, hashcode, tostring") public class thresholdstype implements cloneable, named, visitable, copyto, equals, hashcode, tostring { @xmlelement(name = "threshold") protected list<thresholdtype> threshold; @xmlattribute(name = "interpolate") protected string interpolate; @xmlattribute(name = "parameter") protected string parameter; @xmlattribute(name = "unitsystem") protected string unitsystem; @xmltransient private qname jaxbelementname; ...
i should have renamed "threshold" field inside thresholdstype "thresholds" other works great.
does not work?
<complextype name="tasklist"> <sequence> <element ref="struct:task" maxoccurs="unbounded" minoccurs="0"/> </sequence> </complextype>