Delphi XML Binding Wizard and Additional Elements

In my XSD I have:

  <xs:complexType name="scheduleLocation">
      <xs:element name="arrivalTime" type="hhmmss" default="00:00:00" minOccurs="0"/>
      <xs:element name="departureTime" type="hhmmss" default="00:00:00" minOccurs="0"/>
      <xs:element name="passingTime" type="xs:boolean" default="false" minOccurs="0"/>


The meaning of this is in the following example:



(i.e. no node transit time)

Using D6 XML Data Binding Wizard I get:

function TXMLScheduleLocation.Get_PassingTime: Boolean;
  Result := ChildNodes['passingTime'].NodeValue;


Of course, if I try to get the transmission time value then it fires when no periodTime value is specified in the XML. Is there a way around this - some kind of wizard trick? Also, I think the default is being ignored. Do I have to edit the results?

By the way, xsd.exe generates xxxSpecified fields which would help here.


source to share

1 answer

AFAIK, the XML Data Binding Wizard ignores the defaults, you have to manually encode them:

function TXMLScheduleLocation.Get_PassingTime: Boolean;
 if ChildNodes['passingTime'].NodeValue = null then
  Result := false
  Result := ChildNodes['passingTime'].NodeValue;




All Articles