XML Binding Generation File Does Not Compile

I am working on a project with a Java interface with a Delphi interface. I am trying to create XML bindings based on .xsd in java. XSD contains a TaskList object that has a Tasks item. Tasks is a list of tasks. When I create XML bindings, Delphi tries to create the CreateCollection () function using TXMLTaskList, but throws an error because TXMLTaskList is IXMLNode instead of IXMLNodeCollection.

I'm still new to using XSD files and the function of generating XML bindings, but based on a little understanding, I assumed, since the TaskList contains one Tasks object that it should not use in the CreateCollection Function, instead I will think that tasks that are a list of tasks should be used.

This is the line where my XML bindings file throws an error:

FExportOnClientChange := CreateCollection(TXMLTaskList, IXMLTask, 'exportOnClientChange') as IXMLTaskList; 

This is my TXMLTaskLisk, showing that it is TXMLNode instead of TXMLNodeCollectionClass, which is looking for CreateCollection.

 type TXMLTaskList = class(TXMLNode, IXMLTaskList) protected { IXMLTaskList } function Get_Tasks: IXMLTasks; public procedure AfterConstruction; override; end; 

In my attempts to find out the problem, I noticed that if I make TaskList an unlimited task list and leave the tasks an unlimited task list that everything generates in the delphi xml file, but this will mean that I have a list list that is not what I want.

One thing that can be hard to say here is that TaskList and tasks are in different XSD files, although they are related.

 <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> 
+7
java xml delphi binding xsd
source share
1 answer

You work your own way at Delphi.

With that said, I use xjc and xsd files to create Java classes.

It looks like you included the xsd sample in your question, which, as you know, is wrong. In your xsd example, you have a sequence of sequences - I would expect your sample to generate a class with a collection of collections of task objects.

If I understand your question correctly, then you want the TaskList to contain a set of tasks. It should not be too complicated. What have you tried?

Here is an example of how I generate a Thresholds object that contains a 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 is the beginning of the generated java class of the ThresholdsType 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 had to rename the “threshold” field inside ThresholdsType to “thresholds”, but other than that, it works fine.

Does it work?

 <complexType name="TaskList"> <sequence> <element ref="struct:task" maxOccurs="unbounded" minOccurs="0"/> </sequence> </complexType> 
0
source share

All Articles