REALLY simple xml reader
Ben Finney
bignose+hates-spam at benfinney.id.au
Thu Jan 31 15:51:56 EST 2008
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> On Fri, 01 Feb 2008 00:40:01 +1100, Ben Finney wrote:
>
> > Quite apart from a human thinking it's pretty or not pretty, it's *not
> > valid XML* if the XML declaration isn't immediately at the start of the
> > document <URL:http://www.w3.org/TR/xml/#sec-prolog-dtd>. Many XML
> > parsers will (correctly) reject such a document.
>
> You know, I'd really like to know what the designers were thinking when
> they made this decision.
Probably much the same that the designers of the Unix shebang ("#!")
or countless other "figure out whether the bitstream is a specific
type" were thinking:
It's better to be as precise as possible so that failure can be
unambiguous, than to have more-complex parsing rules that lead to
ambiguity in implementation.
Also, for XML documents, they were probably thinking that the
documents will be machine-generated most of the time. As far as I can
tell, they were right in that.
Given that, I think the choice of precise parsing rules that are
simple to implement correctly (even if the rules themselves are
necessarily complex) is a better one.
--
\ "Those who will not reason, are bigots, those who cannot, are |
`\ fools, and those who dare not, are slaves." —"Lord" George |
_o__) Gordon Noel Byron |
Ben Finney
More information about the Python-list
mailing list