From: ser@... (Sean Russell) Date: 2003-02-24T03:07:35+09:00 Subject: Re: Validating REXML Was Re: ANN: REXML 2.5.4 John Carter wrote in message news:... .... > Problem 3, check that the XML conforms to the Schema (DTD). This is the > missing bit. .... > It merely means you need to traverse the DOM, (which REXML makes really > easy), and at each point check whether this item is valid here. REXML > makes querying the Relax Schema easy too. > > One of the marks of a good compiler is that it can make sensible fixups > and keep going. But for the purposes of validating XML you usually just > want to say, "Aye! It fits", or "Nay! It doesn't, expected XXX at line NNN col MM" > > I bet it won't be a large program at all. > > I would write it now, except I have other things to do first. I mentioned > it now, since I can forsee a future where I will need it, and will have to > write it. > > I just hoped that by the time I need it, someone else would have done so > first. (Larry Wall of Perl says the primary virtues of a programmer are > Laziness, Impatience and Hubris. I don't have the pressing need right now, > so I'm not Impatient on this one, but Laziness tells me I will need it. > Hubris tells me my idea is a "Better way".) John, shoot me an email, and we'll collaborate on this. My plan, as it has stood for the past 5 months, is to write a RelaxNG -> Ruby state machine generator, then slap a SAX2 interface on it. To validate, users will instantiate the validator and pass it to the parser. The parser will call its usual listener notification events; as far as REXML will be concerned, the validator will be just another listener. The validator will just make sure that the events it receives puts the state machine into a valid state. I'll need to add some hooks into REXML to support validation in tree parsing, unless I can think of a less invasive solution, but I'm more than willing to do that work to get validation. I'm hoping that other people will follow the RelaxNG example, and write DTD->FSM and W3C XML Schema->FSM converters. I'd like this mostly because I have zero interest in writing DTD /or/ W3C XSD parsers, so if someone else doesn't do them, they probably will never be done. I'm happy to give contributors repository accounts and as much support as they need to do this work. I've started on this a number of times, and then gotten distracted with other things (like bug fixes). My main task right now is to improve namespace handling in the streaming and pull parsers; I think I *just* fixed the last namespace non-conformance in REXML in this next release. I've also got a dozen other "important" sub-projects, such as trying to separate the various parsers so that people can trim down REXML to a minimal API subset, for inclusion in their own applications. If REXML is ever bundled with Ruby, this won't be as important, but I'd still like to do it to clean up the code base. The API documentation is in total chaos, I need to extend XPath support to do more than return nodes, and then there's XPath 2.0 looming -- that'll be a huge job. Anyway, if anyone is interested in collaborating on the RelaxNG validator, let me know and we'll get started.