From: Sean Russell Date: 2002-06-11T02:17:20+09:00 Subject: RE: ANN: REXML 2.3.5 && 2.2.3 james@rubyxml.com wrote: > Are there validation schemes that require the entire document be in memory > before validation can occur? How many schemes allow for validation while I don't think so, but consider how you're going to do validation outside of the parser. You're either going to: (a) parse the document in tree mode and then validate the tree (requiring the entire document to be in memory), or (b) provide some sort of stream validator that validates and then propagates the events to the end listeners. (b) sounds like more work to me. > token parsing? I'm just wondering how much more efficient it is to > validate while parsing, if the parser is otherwise only concerned with > balanced angle braces and nested tags. Well, you're doing the same amount of work, only if you do the validation while you're parsing, you only have to walk the tree once. O(n) vs O(2n). > Why do you say that? My admittedly distorted view of things suggests that > validation is desirable in only a small number of cases. Maybe because you tend to look at XML from a document point of view, rather than a data point of view (I'm making some bold assumptions with that statement :-) When XML is being used as a process communication mechanism -- say, via RPC or some other logic-to-logic communication -- validation is /extremely/ important. Validation can either be done in the logic, or in the processing, or both. When I'm concerned about accuracy of the data (say, in a balance transfer between bank accounts), I tend to believe that you can't have enough validation. > I mean that something like a DTD can define implied attributes and values, > so a document instance can omit them; the validation process adds them. For DTDs. RelaxNG, as I understand it, specifically omits implied attributes. This was done because /with/ implied attributes, the behavior of an application differs depending on whether the document was validated or not -- if it wasn't validated, it doesn't have the implied attributes. I agree with RelaxNG WRT this point. > Still, given a hammer, everything starts to look like a nail. Given Ruby, every problem looks like a game. ;-) > W3C Schemas look a bit like a solution in search of a problem. Perhaps > too many database people thinking, "well, if we ever get around to using > XML, we're going to need certain things ..." Or vendors realizing that > they'll sell more tools if it gets to hard to roll your own. Yes, definitely. Actually, W3C XML Schema looks to me like a bad case of ivory-tower-itis, designed by people who never have, and probably never will, use the darned thing. -- |.. "They that can give up essential liberty to obtain a little <|> temporary safety deserve neither liberty nor safety." /|\ -- Benjamin Franklin /| |