Delphi XML Binding Wizard and Additional Elements

In my XSD I have:

  <xs:complexType name="scheduleLocation">
    <xs:sequence>
      <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"/>
    </xs:sequence>
  </xs:complexType>

      

The meaning of this is in the following example:

<scheduleLocation>
  <arrivalTime>07:33:00</arrivalTime>
  <departureTime>07:34:00</departureTime>
</scheduleLocation>

      

(i.e. no node transit time)

Using D6 XML Data Binding Wizard I get:

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

      

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.

+3


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;
begin
 if ChildNodes['passingTime'].NodeValue = null then
  Result := false
 else
  Result := ChildNodes['passingTime'].NodeValue;
end;

      

+2


source







All Articles