Verification: An Ally of Validation
   During parsing, the verify() method is invoked on every new node.
   It allows a developer to call 'semantic' processing in a generic way.
   It's easy!
   An editor can highlight verification errors in XML source.
   It's performed during parsing, so post-parse pass not required.
   It currently adds 3-5% to parse time (with a very slow parser!).
   It's easy to switch off.
Warning! The remaining material is suitable for mature audiences only!
   (You can cheat, and do hard-wired validation too.)

Previous     Next

The Node Type Registry allows specialised element classes to be dynamically instantiated during the parse. This makes it easy to invoke specialised processing on each node as soon as it has been parsed, which has been implemented by the verify() method (of which there is an empty implementation in the xg_Node class). Each element's verify() method is free to do whatever it wishes: perform semantic checking (things that validation cannot do), and also additional initialization.

Since this processing is performed as part of the parse, an editor can highlight verification errors based upon the position in the source it has reached (just as if it were a syntax error). Furthermore, a second pass is not required through the grove to complete their initialization.

(Of course, this scheme can be used to do checking that a validating parser can perform with reference to the DTD - but contemplation of such activity must be wholeheartedly condemned. To skate on thin ice for a little longer, it is worth observing that this would allow a non-validating parser to do whatever you wished.)