Link to home
Start Free TrialLog in
Avatar of Wim ten Brink
Wim ten BrinkFlag for Netherlands

asked on

[XML] Delphi 7 XML Data Binding is flawed?

Okay, I wonder if there are more problems with the XML Data Binding wizard than the ones I found. I found that:
1) Adding child nodes to a sequence node will not add them in the order that is required by the sequence.
2) Boolean values are written as 'True' or 'False' while XML is case-sensitive and expects them to be 'true' or 'false'.
3) DateTime fields are not written in the XML-specific format.

About that first issue... If I have this schema-declaration:

  <xs:complexType name="NamedItem">
    <xs:sequence>
      <xs:element name="Name" minOccurs="0" type="xs:string"/>
      <xs:element name="Description" minOccurs="0" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

Now, in Delphi. If I create a node of type NamedItem and add a description before the name, the XML file will look like this:
<NamedItem><Description>adescription</Description><Name>aname</Name><NamedItem>
However, the schema specified that they should be a sequence so I expected Delphi to put these nodes in the right order!

So far, the issues I've found are things I can accept for now. I realise these errors might require me to work around them if I want to output an xml file that validates according to my schema. But I wonder if there are even more problems with Delphi's implementation of XML.

My problem: I have an xml schema and I need to generate/read/write an xml file and make sure it is valid according to this schema. A simple solution is to modify the sourcecode that is generated by the XML data Binding wizard and I just have to make sure I insert elements in the right order. But I wonder if I can expect even more problems.

And no, I don't want or need any alternative XML components, no matter how good they are, how fast they are or how free they are.

Points will be divided if more than one person mentions possible problems that haven't been mentioned before.
Avatar of DeerBear
DeerBear

Hi,

I don't own D7, but to my experience a hotspot is entities' handling( &egrave;&lt;&gt; etc ) which may
well be flawed and if I was you I'd investigate in that direction.

HTH,

Andrew
ASKER CERTIFIED SOLUTION
Avatar of Chopinke
Chopinke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Wim ten Brink

ASKER

Good link, Charlie! :-)
However, it is SOAP related and all I need to do is read/write configuration files containing all kinds of information. I have schemas for these files and must make sure that whatever I write will be validated (e.g. by using XMLSpy) according to these schemas. The biggest thing I actually need to rewrite is the XML Data Binding wizard since this thing generated a flawed sourcefile.

Andrew,
I use the IXMLDocument/TXMLDocument component to access the xml data and haven't noticed many problems with values in entities. It recognizes &lt; and &gt; but &egrave; is invalid. But this is correct since XML doesn't recognise this character reference. Only &amp; &lt; &gt; &quot; &apos; are recognized, which is correct. Other references are just invalid. (Well, unicode chartacters can be referenced by using &#xxx; where xxx is the numeric code for the character. Thus &#0169; will put the © character in the entity. But there's no real need to reference unicode since an XML file can handle unicode files quite well.
Points and A-Grade awarded for the useful link. I hoped someone else might have added something useful to this Q so I would have to split the points but no... No one else added anything. The link explains the weaknesses of Delphi's SOAP implementation and gave me enough leads to discover some other flaws.

Thanks again!