Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-02

Generic XML question

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marc Weustink

Hi,
This is not a specific lazarus question, but since here might be xml users, I'll ask it here.
At my work our software interfaces with a lot of different systems, some of them communicate through a binary protocol and some of them use xml to encode data. YEars ago we coded our own xml parser (creates an object tree of elements found) / generator (generates xml form such tree) Anyway each time I have to communicate with xml there are some "issues" One system for instance doesn't like spaces before the first element or a linefeed after the closing element. Another system ignores the xml message when it encounters an not yet known element (its hard to implement forward/backward compatibility this way). Yesterday I was working on a new system and that one complained about unparseble xml when I put some whitespace (space, linefeed) between the first opening tag end the second opening tag.

Now I wonder, is xml supposed to be so strict or are this implementation "issues"

Marc

Reply by email

Unknown author
to Marc Weustink
Marc Weustink wrote 18 lines
Hi, This is not a specific lazarus question, but since here might be xml users, I'll ask it here. At my work our software interfaces with a lot of different systems, some of them communicate through a binary protocol and some of them use xml to encode data. YEars ago we coded our own xml parser (creates an object tree of elements found) / generator (generates xml form such tree) Anyway each time I have to communicate with xml there are some "issues" One system for instance doesn't like spaces before the first element or a linefeed after the closing element. Another system ignores the xml message when it encounters an not yet known element (its hard to implement forward/backward compatibility this way). Yesterday I was working on a new system and that one complained about unparseble xml when I put some whitespace (space, linefeed) between the first opening tag end the second opening tag. Now I wonder, is xml supposed to be so strict or are this implementation "issues"

I would think these are implementation issues. I have a case where the testsuite of a bank accepts an XML message, and the final implementation rejects the same message. The XML is valid, and according to the namespace rules, the message 'content' should also be valid, but because the test/final implementation process the XML differently, you get the weirdest results.

XML namespaces are a typical case of over-engineering, where the various XML implementations differ wildly in their 'interpretation' of the specs. In Delphi I use TXMLDocument, which in turn uses msxml - a pain by all standards: the final output depends on the machine I am running my program on.

That's why I am happy that the FPC XML implementation does what it is told, and does not try to be 'smart' - well, not too much, anyway ;) .

Michael.

Reply by email

Marco van de Voort
to Marc Weustink: This is not a specific lazarus question, but since here might be xml users, I'll ask it…

In our previous episode, Marc Weustink said:

Show quoted text 11 lines
Anyway each time I have to communicate with xml there are some "issues" One system for instance doesn't like spaces before the first element or a linefeed after the closing element. Another system ignores the xml message when it encounters an not yet known element (its hard to implement forward/backward compatibility this way). Yesterday I was working on a new system and that one complained about unparseble xml when I put some whitespace (space, linefeed) between the first opening tag end the second opening tag. Now I wonder, is xml supposed to be so strict or are this implementation "issues"

Implementation issues. We also have a lot of fun with a vendor that compiles his libxml(2?) one version with crlf support(Windows style), and sometimes only with lf support.(Unix style). And he writes unescaped linefeeds in values that apparantly he can read and write with libxml but are not allowed in XML.

So strictly speaking what he writes is not validatable XML, but you simply can't avoid to ignore it. The same problem as e.g. Microsofts funky IE6 html interpretation in the past.

(I use a modified version of the Lazarus laz_* xml routines btw, sanitized a bit to make it work with unicode delphi's. Nowadays I would take FPC's XML implementation for anything serious though)

I've also seen a lot of modification in behaviour with respect to default value. If an app looks up a value in an XML file that isn't there, does it return some typed default value (0, '' and so on), or a hard NIL pointer, SQL null or the like.

Reply by email